From 282062c1d90c2239af836ea4522758c1c7bc2c5c Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Fri, 28 Jun 2019 20:25:44 +0200 Subject: [PATCH] Add some nil guards around cover_cache_info access Managed to get it nil'ed by playing with a sleepcover magnet... --- plugins/coverbrowser.koplugin/covermenu.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/coverbrowser.koplugin/covermenu.lua b/plugins/coverbrowser.koplugin/covermenu.lua index 100fcafde..80484d9a4 100644 --- a/plugins/coverbrowser.koplugin/covermenu.lua +++ b/plugins/coverbrowser.koplugin/covermenu.lua @@ -229,7 +229,7 @@ function CoverMenu:updateItems(select_number) local orig_purge_callback = orig_buttons[1][3].callback orig_buttons[1][3].callback = function() -- Wipe the cache - if self.cover_info_cache[file] then + if self.cover_info_cache and self.cover_info_cache[file] then self.cover_info_cache[file] = nil end -- And then purge the sidecar folder as expected @@ -242,7 +242,7 @@ function CoverMenu:updateItems(select_number) text_func = function() -- If the book has a cache entry, it means it has a sidecar file, and it *may* have the info we need. local status - if self.cover_info_cache[file] then + if self.cover_info_cache and self.cover_info_cache[file] then local _, _, c_status = unpack(self.cover_info_cache[file]) status = c_status end @@ -256,7 +256,7 @@ function CoverMenu:updateItems(select_number) enabled = true, callback = function() local status - if self.cover_info_cache[file] then + if self.cover_info_cache and self.cover_info_cache[file] then local c_pages, c_percent_finished, c_status = unpack(self.cover_info_cache[file]) status = c_status == "complete" and "reading" or "complete" -- Update the cache, even if it had a nil status before @@ -368,7 +368,7 @@ function CoverMenu:updateItems(select_number) enabled = bookinfo and true or false, callback = function() -- Wipe the cache - if self.cover_info_cache[file] then + if self.cover_info_cache and self.cover_info_cache[file] then self.cover_info_cache[file] = nil end BookInfoManager:deleteBookInfo(file)