#194 #382 ccmsi no longer deletes drive mounts and now prompts to delete unknown files/folders in root

This commit is contained in:
Mikayla Fischler 2023-12-17 20:10:11 -05:00
parent 466e442353
commit 1b20218445

View File

@ -18,7 +18,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local function println(message) print(tostring(message)) end local function println(message) print(tostring(message)) end
local function print(message) term.write(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 install_dir = "/.install-cache"
local manifest_path = "https://mikaylafischler.github.io/cc-mek-scada/manifests/" local manifest_path = "https://mikaylafischler.github.io/cc-mek-scada/manifests/"
@ -168,28 +168,29 @@ end
-- go through app/common directories to delete unused files -- go through app/common directories to delete unused files
local function clean(manifest) local function clean(manifest)
local root_ext = false
local tree = gen_tree(manifest) local tree = gen_tree(manifest)
table.insert(tree, "install_manifest.json") table.insert(tree, "install_manifest.json")
table.insert(tree, "ccmsi.lua") table.insert(tree, "ccmsi.lua")
table.insert(tree, "log.txt") ---@fixme fix after migration to settings files? table.insert(tree, "log.txt") ---@fixme fix after migration to settings files?
lgray()
local ls = fs.list("/") local ls = fs.list("/")
for _, val in pairs(ls) do for _, val in pairs(ls) do
if fs.isDir(val) then if fs.isDriveRoot(val) then
if tree[val] ~= nil then _clean_dir("/" .. val, tree[val]) end yellow();println("skipped mount '" .. val .. "'")
if #fs.list(val) == 0 then fs.delete(val);println("deleted " .. val) end 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 elseif not _in_array(val, tree) and (string.find(val, ".settings") == nil) then
root_ext = true white();if ask_y_n("delete the unused file '" .. val .. "'") then fs.delete(val);lgray();println("deleted " .. val) end
yellow();println(val .. " not used")
end end
end end
white() white()
if root_ext then println("Files in root directory won't be automatically deleted.") end
end end
-- get and validate command line options -- get and validate command line options
@ -347,7 +348,7 @@ elseif mode == "install" or mode == "update" then
if mode == "install" then if mode == "install" then
println("Installing " .. app .. " files...") println("Installing " .. app .. " files...")
elseif mode == "update" then 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)") println("Updating " .. app .. " files... (keeping old config.lua)")
else println("Updating " .. app .. " files...") end else println("Updating " .. app .. " files...") end
end end