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.
pull/4025/head
poire-z 6 years ago committed by GitHub
parent dd9cd0e87e
commit 6877ade4fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -659,7 +659,13 @@ function FileManager:deleteFile(file)
end end
if ok and not err then if ok and not err then
if is_doc then if is_doc then
DocSettings:open(file):purge() local doc_settings = DocSettings:open(file)
-- remove cache if any
local cache_file_path = doc_settings:readSetting("cache_file_path")
if cache_file_path then
os.remove(cache_file_path)
end
doc_settings:purge()
end end
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = util.template(_("Deleted %1"), file), text = util.template(_("Deleted %1"), file),

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

Loading…
Cancel
Save