From fd8cb14c007d7261243b83f13598643b387bb595 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Wed, 26 Apr 2023 10:19:01 +0300 Subject: [PATCH] CoverBrowser: fix getting cached info (#10346) --- plugins/coverbrowser.koplugin/covermenu.lua | 2 +- plugins/coverbrowser.koplugin/listmenu.lua | 3 ++- plugins/coverbrowser.koplugin/mosaicmenu.lua | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/coverbrowser.koplugin/covermenu.lua b/plugins/coverbrowser.koplugin/covermenu.lua index db069c4e0..872797684 100644 --- a/plugins/coverbrowser.koplugin/covermenu.lua +++ b/plugins/coverbrowser.koplugin/covermenu.lua @@ -61,7 +61,7 @@ function CoverMenu:updateCache(file, status, do_create, pages) status = summary and summary.status local highlight = doc_settings:readSetting("highlight") local has_highlight = highlight and next(highlight) and true - self.cover_info_cache[file] = {pages, percent_finished, status, has_highlight} + self.cover_info_cache[file] = table.pack(pages, percent_finished, status, has_highlight) -- may be a sparse array else if self.cover_info_cache and self.cover_info_cache[file] then if status then diff --git a/plugins/coverbrowser.koplugin/listmenu.lua b/plugins/coverbrowser.koplugin/listmenu.lua index 842f73a49..10c97d28c 100644 --- a/plugins/coverbrowser.koplugin/listmenu.lua +++ b/plugins/coverbrowser.koplugin/listmenu.lua @@ -372,7 +372,8 @@ function ListMenuItem:update() if DocSettings:hasSidecarFile(self.filepath) then self.been_opened = true self.menu:updateCache(self.filepath, nil, true, pages) -- create new cache entry if absent - pages, percent_finished, status, has_highlight = unpack(self.menu.cover_info_cache[self.filepath]) + pages, percent_finished, status, has_highlight = + unpack(self.menu.cover_info_cache[self.filepath], 1, self.menu.cover_info_cache[self.filepath].n) end -- right widget, first line local directory, filename = util.splitFilePathName(self.filepath) -- luacheck: no unused diff --git a/plugins/coverbrowser.koplugin/mosaicmenu.lua b/plugins/coverbrowser.koplugin/mosaicmenu.lua index 343a1f548..f723252b3 100644 --- a/plugins/coverbrowser.koplugin/mosaicmenu.lua +++ b/plugins/coverbrowser.koplugin/mosaicmenu.lua @@ -577,7 +577,8 @@ function MosaicMenuItem:update() if DocSettings:hasSidecarFile(self.filepath) then self.been_opened = true self.menu:updateCache(self.filepath, nil, true, bookinfo.pages) -- create new cache entry if absent - dummy, percent_finished, status = unpack(self.menu.cover_info_cache[self.filepath]) + dummy, percent_finished, status = + unpack(self.menu.cover_info_cache[self.filepath], 1, self.menu.cover_info_cache[self.filepath].n) end self.percent_finished = percent_finished self.status = status