Skip to content

Commit

Permalink
#194 #382 ccmsi no longer deletes drive mounts and now prompts to del…
Browse files Browse the repository at this point in the history
…ete unknown files/folders in root
  • Loading branch information
MikaylaFischler committed Dec 18, 2023
1 parent 466e442 commit 1b20218
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ccmsi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local function println(message) print(tostring(message)) end
local function print(message) term.write(tostring(message)) end

local CCMSI_VERSION = "v1.11d"
local CCMSI_VERSION = "v1.12"

local install_dir = "/.install-cache"
local manifest_path = "https://mikaylafischler.github.io/cc-mek-scada/manifests/"
Expand Down Expand Up @@ -168,28 +168,29 @@ end

-- go through app/common directories to delete unused files
local function clean(manifest)
local root_ext = false
local tree = gen_tree(manifest)

table.insert(tree, "install_manifest.json")
table.insert(tree, "ccmsi.lua")
table.insert(tree, "log.txt") ---@fixme fix after migration to settings files?

lgray()

local ls = fs.list("/")
for _, val in pairs(ls) do
if fs.isDir(val) then
if tree[val] ~= nil then _clean_dir("/" .. val, tree[val]) end
if #fs.list(val) == 0 then fs.delete(val);println("deleted " .. val) end
if fs.isDriveRoot(val) then
yellow();println("skipped mount '" .. val .. "'")
elseif fs.isDir(val) then
if tree[val] ~= nil then
lgray();_clean_dir("/" .. val, tree[val])
else
white();if ask_y_n("delete the unused directory '" .. val .. "'") then lgray();_clean_dir("/" .. val, tree[val]) end
end
if #fs.list(val) == 0 then fs.delete(val);lgray();println("deleted empty directory '" .. val .. "'") end
elseif not _in_array(val, tree) and (string.find(val, ".settings") == nil) then
root_ext = true
yellow();println(val .. " not used")
white();if ask_y_n("delete the unused file '" .. val .. "'") then fs.delete(val);lgray();println("deleted " .. val) end
end
end

white()
if root_ext then println("Files in root directory won't be automatically deleted.") end
end

-- get and validate command line options
Expand Down Expand Up @@ -347,7 +348,7 @@ elseif mode == "install" or mode == "update" then
if mode == "install" then
println("Installing " .. app .. " files...")
elseif mode == "update" then
if app == "coordinator" or app == "pocket" then
if app == "supervisor" or app == "coordinator" or app == "pocket" then
println("Updating " .. app .. " files... (keeping old config.lua)")
else println("Updating " .. app .. " files...") end
end
Expand Down

0 comments on commit 1b20218

Please sign in to comment.