Ensure all project files are correctly filtered
This commit is contained in:
parent
58cfee2a58
commit
40cfd079d1
|
@ -99,11 +99,13 @@ end
|
||||||
|
|
||||||
-- compute a file's info entry completed with "filename" to be used
|
-- compute a file's info entry completed with "filename" to be used
|
||||||
-- in project scan or falsy if it shouldn't appear in the list.
|
-- in project scan or falsy if it shouldn't appear in the list.
|
||||||
local function get_project_file_info(root, file, size_limit)
|
local function get_project_file_info(root, file)
|
||||||
local info = system.get_file_info(root .. file)
|
local info = system.get_file_info(root .. file)
|
||||||
if info then
|
if info then
|
||||||
info.filename = strip_leading_path(file)
|
info.filename = strip_leading_path(file)
|
||||||
return info.size < size_limit and info
|
return (info.size < config.file_size_limit * 1e6 and
|
||||||
|
not common.match_pattern(info.filename, config.ignore_files)
|
||||||
|
and info)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -118,22 +120,19 @@ end
|
||||||
-- complete file path relative to "root" *without* the trailing '/'.
|
-- complete file path relative to "root" *without* the trailing '/'.
|
||||||
local function get_directory_files(root, path, t, recursive, begin_hook)
|
local function get_directory_files(root, path, t, recursive, begin_hook)
|
||||||
if begin_hook then begin_hook() end
|
if begin_hook then begin_hook() end
|
||||||
local size_limit = config.file_size_limit * 10e5
|
|
||||||
local all = system.list_dir(root .. path) or {}
|
local all = system.list_dir(root .. path) or {}
|
||||||
local dirs, files = {}, {}
|
local dirs, files = {}, {}
|
||||||
|
|
||||||
local entries_count = 0
|
local entries_count = 0
|
||||||
local max_entries = config.max_project_files
|
local max_entries = config.max_project_files
|
||||||
for _, file in ipairs(all) do
|
for _, file in ipairs(all) do
|
||||||
if not common.match_pattern(file, config.ignore_files) then
|
local info = get_project_file_info(root, path .. PATHSEP .. file)
|
||||||
local info = get_project_file_info(root, path .. PATHSEP .. file, size_limit)
|
|
||||||
if info then
|
if info then
|
||||||
table.insert(info.type == "dir" and dirs or files, info)
|
table.insert(info.type == "dir" and dirs or files, info)
|
||||||
entries_count = entries_count + 1
|
entries_count = entries_count + 1
|
||||||
if recursive and entries_count > max_entries then return nil, entries_count end
|
if recursive and entries_count > max_entries then return nil, entries_count end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
table.sort(dirs, compare_file)
|
table.sort(dirs, compare_file)
|
||||||
for _, f in ipairs(dirs) do
|
for _, f in ipairs(dirs) do
|
||||||
|
@ -311,13 +310,11 @@ end
|
||||||
-- Filter files and yields file's directory and info table. This latter
|
-- Filter files and yields file's directory and info table. This latter
|
||||||
-- is filled to be like required by project directories "files" list.
|
-- is filled to be like required by project directories "files" list.
|
||||||
local function find_files_rec(root, path)
|
local function find_files_rec(root, path)
|
||||||
local size_limit = config.file_size_limit * 10e5
|
|
||||||
local all = system.list_dir(root .. path) or {}
|
local all = system.list_dir(root .. path) or {}
|
||||||
for _, file in ipairs(all) do
|
for _, file in ipairs(all) do
|
||||||
if not common.match_pattern(file, config.ignore_files) then
|
|
||||||
local file = path .. PATHSEP .. file
|
local file = path .. PATHSEP .. file
|
||||||
local info = system.get_file_info(root .. file)
|
local info = system.get_file_info(root .. file)
|
||||||
if info and info.size < size_limit then
|
if info then
|
||||||
info.filename = strip_leading_path(file)
|
info.filename = strip_leading_path(file)
|
||||||
if info.type == "file" then
|
if info.type == "file" then
|
||||||
coroutine.yield(root, info)
|
coroutine.yield(root, info)
|
||||||
|
@ -327,7 +324,6 @@ local function find_files_rec(root, path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Iterator function to list all project files
|
-- Iterator function to list all project files
|
||||||
|
@ -412,8 +408,7 @@ local function project_scan_add_file(dir, filepath)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local size_limit = config.file_size_limit * 10e5
|
local fileinfo = get_project_file_info(dir.name, PATHSEP .. filepath)
|
||||||
local fileinfo = get_project_file_info(dir.name, PATHSEP .. filepath, size_limit)
|
|
||||||
if fileinfo then
|
if fileinfo then
|
||||||
project_scan_add_entry(dir, fileinfo)
|
project_scan_add_entry(dir, fileinfo)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue