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 local path = statistics_dir .. curr_file
if lfs.attributes(path, "mode") == "file" then if lfs.attributes(path, "mode") == "file" then
local book_result = self:importFromFile(statistics_dir, curr_file) 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 book_result.title ~= self.data.title
and not exlude_titles[book_result.title] then and not exlude_titles[book_result.title] then
table.insert(total_stats, { table.insert(total_stats, {
@ -374,15 +374,17 @@ end
-- For backward compatibility -- For backward compatibility
function ReaderStatistics:importFromFile(base_path, item) function ReaderStatistics:importFromFile(base_path, item)
item = string.gsub(item, "^%s*(.-)%s*$", "%1") -- trim item = string.gsub(item, "^%s*(.-)%s*$", "%1") -- trim
local statistic_file = joinPath(base_path, item) if item ~= ".stat" then
if lfs.attributes(statistic_file, "mode") == "directory" then local statistic_file = joinPath(base_path, item)
return if lfs.attributes(statistic_file, "mode") == "directory" then
end return
local ok, stored = pcall(dofile, statistic_file) end
if ok then local ok, stored = pcall(dofile, statistic_file)
return stored if ok then
else return stored
DEBUG(stored) else
DEBUG(stored)
end
end end
end end

Loading…
Cancel
Save