fix error in case when process old statistics files

pull/1819/head
Alex Pletnev 8 years ago
parent 271b79b039
commit 853e8581d0

@ -316,7 +316,7 @@ function ReaderStatistics:getOldStatisticsFromDirectory(exlude_titles, total_sta
local path = statistics_dir .. curr_file
if lfs.attributes(path, "mode") == "file" then
local book_result = self:importFromFile(statistics_dir, curr_file)
if book_result and book_stats.total_time_in_sec > 0
if book_result and book_result.total_time > 0
and book_result.title ~= self.data.title
and not exlude_titles[book_result.title] then
table.insert(total_stats, {
@ -374,6 +374,7 @@ end
-- For backward compatibility
function ReaderStatistics:importFromFile(base_path, item)
item = string.gsub(item, "^%s*(.-)%s*$", "%1") -- trim
if item ~= ".stat" then
local statistic_file = joinPath(base_path, item)
if lfs.attributes(statistic_file, "mode") == "directory" then
return
@ -384,6 +385,7 @@ function ReaderStatistics:importFromFile(base_path, item)
else
DEBUG(stored)
end
end
end
function ReaderStatistics:onCloseDocument()

Loading…
Cancel
Save