Wallabag: skip archive dir in recursive scan (#15767)
Including the archive dir in the result of Wallabag:getLocalArticles
causes all archived articles' statuses to be synced with Wallabag every
time. That leads to an increase in sync times from seconds to minutes
(or even more if one's archive is larger than hundreds…).
The fix is simple: skip the archive dir when scanning.
(As a side effect, this allows one to organise their archive dir using
subdirs, which is similar to the motivation of the PR that broke this…)
Fixes: 896646bf8b ("Reworked the Wallabag plugin to recursively scan the download directory (#15558)")
Fixes: https://github.com/koreader/koreader/pull/15558#issuecomment-5136923551
This commit is contained in:
1 parent
820ad724ac
commit
9192014d8b
1 file changed
+7
-7
@@ -1421,15 +1421,11 @@ function Wallabag:archiveLocalArticle(path)
|
|||||||
if lfs.attributes(path, "mode") == "file" then
|
if lfs.attributes(path, "mode") == "file" then
|
||||||
local _, file = util.splitFilePathName(path)
|
local _, file = util.splitFilePathName(path)
|
||||||
local new_path = ffiUtil.joinPath(self.archive_directory, file)
|
local new_path = ffiUtil.joinPath(self.archive_directory, file)
|
||||||
if path == new_path then -- Already archived
|
if FileManager:moveFile(path, new_path) then
|
||||||
result = true
|
result = true
|
||||||
else
|
|
||||||
if FileManager:moveFile(path, new_path) then
|
|
||||||
result = true
|
|
||||||
end
|
|
||||||
DocSettings.updateLocation(path, new_path, false) -- move sdr
|
|
||||||
--- @todo Why is sdr copied instead of moved?
|
|
||||||
end
|
end
|
||||||
|
DocSettings.updateLocation(path, new_path, false) -- move sdr
|
||||||
|
--- @todo Why is sdr copied instead of moved?
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -1489,6 +1485,10 @@ function Wallabag:getLocalArticles(dir, map)
|
|||||||
map = {}
|
map = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if dir == self.archive_directory then
|
||||||
|
return map
|
||||||
|
end
|
||||||
|
|
||||||
for entry in lfs.dir(dir) do
|
for entry in lfs.dir(dir) do
|
||||||
if entry ~= "." and entry ~= ".." then
|
if entry ~= "." and entry ~= ".." then
|
||||||
local entry_path = ffiUtil.joinPath(dir, entry)
|
local entry_path = ffiUtil.joinPath(dir, entry)
|
||||||
|
|||||||
Reference in new issue
Block a user