Remove cre cache file when deleting a book (#4022)

Store the cache file path in book settings, so we can
delete it too when deleting the book.
This commit is contained in:
poire-z
2018-06-25 23:38:02 +02:00
committed by GitHub
parent dd9cd0e87e
commit 6877ade4fd
2 changed files with 14 additions and 6 deletions

View File

@@ -180,15 +180,17 @@ end
-- we cannot do it in onSaveSettings() because getLastPercent() uses self.ui.document
function ReaderRolling:onCloseDocument()
self.ui.doc_settings:saveSetting("percent_finished", self:getLastPercent())
-- also checks if DOM is coherent with styles; if not, invalidate the
-- cache, so a new DOM is built on next opening
if self.ui.document:isBuiltDomStale() then
if self.ui.document:hasCacheFile() then
local cache_file_path = self.ui.document:getCacheFilePath() -- nil if no cache file
self.ui.doc_settings:saveSetting("cache_file_path", cache_file_path)
if self.ui.document:hasCacheFile() then
-- also checks if DOM is coherent with styles; if not, invalidate the
-- cache, so a new DOM is built on next opening
if self.ui.document:isBuiltDomStale() then
logger.dbg("cre DOM may not be in sync with styles, invalidating cache file for a full reload at next opening")
self.ui.document:invalidateCacheFile()
end
end
logger.dbg("cre cache used:", self.ui.document:getCacheFilePath() or "none")
logger.dbg("cre cache used:", cache_file_path or "none")
end
function ReaderRolling:onCheckDomStyleCoherence()