mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
File search & BookInfo: Don't traverse hidden folders if we're not showing them (#5816)
* File search: Don't traverse hidden folders if we're not showing them Re https://www.mobileread.com/forums/showpost.php?p=3949194&postcount=21 * Ignore macOS resource forks, too. * Apply the same logic to the BookInfo directory walker * And never ever show resource forks in the FM, either.
This commit is contained in:
@@ -7,7 +7,8 @@ local InputDialog = require("ui/widget/inputdialog")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local util = require("ffi/util")
|
||||
local BaseUtil = require("ffi/util")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local Screen = require("device").screen
|
||||
|
||||
@@ -38,10 +39,12 @@ function FileSearcher:readDir()
|
||||
for f in lfs.dir(d) do
|
||||
local fullpath = d.."/"..f
|
||||
local attributes = lfs.attributes(fullpath) or {}
|
||||
if attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
-- Don't traverse hidden folders if we're not showing them
|
||||
if attributes.mode == "directory" and f ~= "." and f ~= ".." and (G_reader_settings:isTrue("show_hidden") or not util.stringStartsWith(f, ".")) then
|
||||
table.insert(new_dirs, fullpath)
|
||||
table.insert(self.files, {name = f, path = fullpath, attr = attributes})
|
||||
elseif attributes.mode == "file" and DocumentRegistry:hasProvider(fullpath) then
|
||||
-- Always ignore macOS resource forks, too.
|
||||
elseif attributes.mode == "file" and not util.stringStartsWith(f, "._") and DocumentRegistry:hasProvider(fullpath) then
|
||||
table.insert(self.files, {name = f, path = fullpath, attr = attributes})
|
||||
end
|
||||
end
|
||||
@@ -93,7 +96,7 @@ function FileSearcher:close()
|
||||
else
|
||||
UIManager:show(
|
||||
InfoMessage:new{
|
||||
text = util.template(_("Found no files matching '%1'."),
|
||||
text = BaseUtil.template(_("Found no files matching '%1'."),
|
||||
self.search_value)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -65,14 +65,15 @@ function FileChooser:init()
|
||||
local filename = path.."/"..f
|
||||
local attributes = lfs.attributes(filename)
|
||||
if attributes ~= nil then
|
||||
if attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
if attributes.mode == "directory" and f ~= "." and f ~= ".." then
|
||||
if self.dir_filter(filename) then
|
||||
table.insert(dirs, {name = f,
|
||||
suffix = getFileNameSuffix(f),
|
||||
fullpath = filename,
|
||||
attr = attributes})
|
||||
end
|
||||
elseif attributes.mode == "file" then
|
||||
-- Always ignore macOS resource forks.
|
||||
elseif attributes.mode == "file" and not util.stringStartsWith(f, "._") then
|
||||
if self.file_filter == nil or self.file_filter(filename) or self.show_unsupported then
|
||||
local percent_finished = 0
|
||||
if self.collate == "percent_unopened_first" or self.collate == "percent_unopened_last" then
|
||||
|
||||
@@ -661,9 +661,11 @@ local function findFilesInDir(path, recursive)
|
||||
for f in lfs.dir(d) do
|
||||
local fullpath = d.."/"..f
|
||||
local attributes = lfs.attributes(fullpath)
|
||||
if recursive and attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
-- Don't traverse hidden folders if we're not showing them
|
||||
if recursive and attributes.mode == "directory" and f ~= "." and f ~= ".." and (G_reader_settings:isTrue("show_hidden") or not util.stringStartsWith(f, ".")) then
|
||||
table.insert(new_dirs, fullpath)
|
||||
elseif attributes.mode == "file" and DocumentRegistry:hasProvider(fullpath) then
|
||||
-- Always ignore macOS resource forks, too.
|
||||
elseif attributes.mode == "file" and not util.stringStartsWith(f, "._") and DocumentRegistry:hasProvider(fullpath) then
|
||||
table.insert(files, fullpath)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user