Fix sort-by-last-read when partition is mounted noatime (#3990)

pull/3992/head
alethiophile 6 years ago committed by Frans de Jonge
parent 6abc1262dd
commit 4c8ef61477

@ -181,9 +181,15 @@ end
function ReadHistory:addItem(file)
assert(self ~= nil)
if file ~= nil and lfs.attributes(file, "mode") == "file" then
table.insert(self.hist, 1, buildEntry(os.time(), file))
local now = os.time()
table.insert(self.hist, 1, buildEntry(now, file))
-- TODO(zijiehe): We do not need to sort if we can use binary insert and
-- binary search.
-- util.execute("/bin/touch", "-a", file)
-- This emulates `touch -a` in LuaFileSystem's API, since it may be absent (Android)
-- or provided by busybox, which doesn't support the `-a` flag.
local mtime = lfs.attributes(file, "modification")
lfs.touch(file, now, mtime)
self:_sort()
self:_reduce()
self:_flush()

Loading…
Cancel
Save