mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
FileManagerHistory: remove harmful deletion code and turn it into a feature
Fixes the problem introduced in 51327911f2 and turns it into a feature that should fix #2477
This commit is contained in:
committed by
Qingping Hou
parent
8b95b8fd96
commit
2c80ff7d7b
@@ -128,6 +128,17 @@ function FileManagerHistory:onMenuHold(item)
|
||||
end,
|
||||
},
|
||||
},
|
||||
{},
|
||||
{
|
||||
{
|
||||
text = _("Clear history of deleted files"),
|
||||
callback = function()
|
||||
require("readhistory"):clearMissing()
|
||||
self._manager:updateItemTable()
|
||||
UIManager:close(self.histfile_dialog)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
UIManager:show(self.histfile_dialog)
|
||||
|
||||
@@ -47,11 +47,6 @@ function ReadHistory:_indexing(start)
|
||||
end
|
||||
|
||||
function ReadHistory:_sort()
|
||||
for i = #self.hist, 1, -1 do
|
||||
if self.hist[i].file == nil or lfs.attributes(self.hist[i].file, "mode") ~= "file" then
|
||||
table.remove(self.hist, i)
|
||||
end
|
||||
end
|
||||
table.sort(self.hist, fileFirstOrdering)
|
||||
-- TODO(zijiehe): Use binary insert instead of a loop to deduplicate.
|
||||
for i = #self.hist, 2, -1 do
|
||||
@@ -122,6 +117,14 @@ function ReadHistory:_init()
|
||||
self:_reduce()
|
||||
end
|
||||
|
||||
function ReadHistory:clearMissing()
|
||||
for i = #self.hist, 1, -1 do
|
||||
if self.hist[i].file == nil or lfs.attributes(self.hist[i].file, "mode") ~= "file" then
|
||||
table.remove(self.hist, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ReadHistory:removeItem(item)
|
||||
table.remove(self.hist, item.index)
|
||||
os.remove(DocSettings:getHistoryPath(item.file))
|
||||
|
||||
Reference in New Issue
Block a user