From 51327911f2fbea00258717d7b284e061ad31832e Mon Sep 17 00:00:00 2001 From: Hzj_jie Date: Thu, 21 Apr 2016 20:37:16 -0700 Subject: [PATCH] Won't track missing files in history, and always keep latest timestamp --- frontend/readhistory.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/readhistory.lua b/frontend/readhistory.lua index dd5eb4791..e0c2c837e 100644 --- a/frontend/readhistory.lua +++ b/frontend/readhistory.lua @@ -23,11 +23,20 @@ local function buildEntry(input_time, input_file) end 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) -- TODO(zijiehe): Use binary insert instead of a loop to deduplicate. for i = #self.hist, 2, -1 do 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 table.sort(self.hist, function(v1, v2) return v1.time > v2.time end)