Backup and restore bookmarks/highlights: fix logic (#8473)

This commit is contained in:
hius07
2021-11-23 02:11:07 +02:00
committed by GitHub
parent a2d95f5a3f
commit 1c9e21389d
2 changed files with 24 additions and 5 deletions

View File

@@ -268,17 +268,26 @@ function ReaderBookmark:onReadSettings(config)
-- Bookmark formats in crengine and mupdf are incompatible.
-- Backup bookmarks when the document is opened with incompatible engine.
if #self.bookmarks > 0 then
if self.ui.rolling and type(self.bookmarks[1].page) == "number" then
local bookmarks_type = type(self.bookmarks[1].page)
if self.ui.rolling and bookmarks_type == "number" then
config:saveSetting("bookmarks_paging", self.bookmarks)
self.bookmarks = config:readSetting("bookmarks_rolling", {})
config:saveSetting("bookmarks", self.bookmarks)
config:delSetting("bookmarks_rolling")
elseif self.ui.paging and type(self.bookmarks[1].page) == "string" then
elseif self.ui.paging and bookmarks_type == "string" then
config:saveSetting("bookmarks_rolling", self.bookmarks)
self.bookmarks = config:readSetting("bookmarks_paging", {})
config:saveSetting("bookmarks", self.bookmarks)
config:delSetting("bookmarks_paging")
end
else
if self.ui.rolling and config:has("bookmarks_rolling") then
self.bookmarks = config:readSetting("bookmarks_rolling")
config:delSetting("bookmarks_rolling")
elseif self.ui.paging and config:has("bookmarks_paging") then
self.bookmarks = config:readSetting("bookmarks_paging")
config:delSetting("bookmarks_paging")
end
end
-- need to do this after initialization because checking xpointer
-- may cause segfaults before credocuments are inited.