mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
Merge pull request #1984 from Hzj-jie/master
Won't track missing files in history, and always keep latest timestamp
This commit is contained in:
@@ -23,11 +23,20 @@ local function buildEntry(input_time, input_file)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ReadHistory:_sort()
|
function ReadHistory:_sort()
|
||||||
|
for i = #self.hist, 1, -1 do
|
||||||
|
if lfs.attributes(self.hist[i].file, "mode") ~= "file" then
|
||||||
|
table.remove(self.hist, i)
|
||||||
|
end
|
||||||
|
end
|
||||||
table.sort(self.hist, function(l, r) return l.file < r.file end)
|
table.sort(self.hist, function(l, r) return l.file < r.file end)
|
||||||
-- TODO(zijiehe): Use binary insert instead of a loop to deduplicate.
|
-- TODO(zijiehe): Use binary insert instead of a loop to deduplicate.
|
||||||
for i = #self.hist, 2, -1 do
|
for i = #self.hist, 2, -1 do
|
||||||
if self.hist[i].file == self.hist[i - 1].file then
|
if self.hist[i].file == self.hist[i - 1].file then
|
||||||
table.remove(self.hist, i)
|
if self.hist[i].time < self.hist[i - 1].time then
|
||||||
|
table.remove(self.hist, i)
|
||||||
|
else
|
||||||
|
table.remove(self.hist,i - 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(self.hist, function(v1, v2) return v1.time > v2.time end)
|
table.sort(self.hist, function(v1, v2) return v1.time > v2.time end)
|
||||||
|
|||||||
Reference in New Issue
Block a user