From 73996e3dc9efc240aaa962fd8402bf6d72b6b5da Mon Sep 17 00:00:00 2001 From: rxi Date: Wed, 6 May 2020 17:03:10 +0100 Subject: [PATCH] Changed core to store `modified` and `size` in project_files table --- data/core/init.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 04284b26..1626fca7 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -17,12 +17,17 @@ local function project_scan_thread() local function diff_files(a, b) if #a ~= #b then return true end for i, v in ipairs(a) do - if b[i].filename ~= v.filename or b[i].type ~= v.type then + if b[i].filename ~= v.filename + or b[i].modified ~= v.modified then return true end end end + local function compare_file(a, b) + return a.filename < b.filename + end + local function get_files(path, t) coroutine.yield() t = t or {} @@ -35,20 +40,21 @@ local function project_scan_thread() local file = path .. PATHSEP .. file local info = system.get_file_info(file) if info and info.size < size_limit then - table.insert(info.type == "dir" and dirs or files, file) + info.filename = file + table.insert(info.type == "dir" and dirs or files, info) end end end - table.sort(dirs) - for _, dir in ipairs(dirs) do - table.insert(t, { filename = dir, type = "dir" }) - get_files(dir, t) + table.sort(dirs, compare_file) + for _, f in ipairs(dirs) do + table.insert(t, f) + get_files(f.filename, t) end - table.sort(files) - for _, file in ipairs(files) do - table.insert(t, { filename = file, type = "file" }) + table.sort(files, compare_file) + for _, f in ipairs(files) do + table.insert(t, f) end return t