Changed core to store modified and size in project_files table

This commit is contained in:
rxi 2020-05-06 17:03:10 +01:00
parent 5361bfaf9c
commit 73996e3dc9

View file

@ -17,12 +17,17 @@ local function project_scan_thread()
local function diff_files(a, b) local function diff_files(a, b)
if #a ~= #b then return true end if #a ~= #b then return true end
for i, v in ipairs(a) do 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 return true
end end
end end
end end
local function compare_file(a, b)
return a.filename < b.filename
end
local function get_files(path, t) local function get_files(path, t)
coroutine.yield() coroutine.yield()
t = t or {} t = t or {}
@ -35,20 +40,21 @@ local function project_scan_thread()
local file = path .. PATHSEP .. file local file = path .. PATHSEP .. file
local info = system.get_file_info(file) local info = system.get_file_info(file)
if info and info.size < size_limit then 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 end
end end
table.sort(dirs) table.sort(dirs, compare_file)
for _, dir in ipairs(dirs) do for _, f in ipairs(dirs) do
table.insert(t, { filename = dir, type = "dir" }) table.insert(t, f)
get_files(dir, t) get_files(f.filename, t)
end end
table.sort(files) table.sort(files, compare_file)
for _, file in ipairs(files) do for _, f in ipairs(files) do
table.insert(t, { filename = file, type = "file" }) table.insert(t, f)
end end
return t return t