|
|
@ -59,29 +59,33 @@ function BookInfo:show(file, book_props)
|
|
|
|
-- book_props may be provided if caller already has them available
|
|
|
|
-- book_props may be provided if caller already has them available
|
|
|
|
-- but it may lack 'pages', that we may get from sidecar file
|
|
|
|
-- but it may lack 'pages', that we may get from sidecar file
|
|
|
|
if not book_props or not book_props.pages then
|
|
|
|
if not book_props or not book_props.pages then
|
|
|
|
local doc_settings = DocSettings:open(file)
|
|
|
|
-- check there is actually a sidecar file before calling DocSettings:open()
|
|
|
|
if doc_settings then
|
|
|
|
-- that would create an empty sidecar directory
|
|
|
|
if not book_props then
|
|
|
|
if DocSettings:hasSidecarFile(file) then
|
|
|
|
-- Files opened after 20170701 have a 'doc_props' setting with
|
|
|
|
local doc_settings = DocSettings:open(file)
|
|
|
|
-- complete metadata and 'doc_pages' with accurate nb of pages
|
|
|
|
if doc_settings then
|
|
|
|
book_props = doc_settings:readSetting('doc_props')
|
|
|
|
if not book_props then
|
|
|
|
end
|
|
|
|
-- Files opened after 20170701 have a 'doc_props' setting with
|
|
|
|
if not book_props then
|
|
|
|
-- complete metadata and 'doc_pages' with accurate nb of pages
|
|
|
|
-- File last opened before 20170701 may have a 'stats' setting
|
|
|
|
book_props = doc_settings:readSetting('doc_props')
|
|
|
|
-- with partial metadata, or empty metadata if statistics plugin
|
|
|
|
end
|
|
|
|
-- was not enabled when book was read (we can guess that from
|
|
|
|
if not book_props then
|
|
|
|
-- the fact that stats.page = 0)
|
|
|
|
-- File last opened before 20170701 may have a 'stats' setting
|
|
|
|
local stats = doc_settings:readSetting('stats')
|
|
|
|
-- with partial metadata, or empty metadata if statistics plugin
|
|
|
|
if stats and stats.pages ~= 0 then
|
|
|
|
-- was not enabled when book was read (we can guess that from
|
|
|
|
-- Let's use them as is (which was what was done before), even if
|
|
|
|
-- the fact that stats.page = 0)
|
|
|
|
-- incomplete, to avoid expensive book opening
|
|
|
|
local stats = doc_settings:readSetting('stats')
|
|
|
|
book_props = stats
|
|
|
|
if stats and stats.pages ~= 0 then
|
|
|
|
|
|
|
|
-- Let's use them as is (which was what was done before), even if
|
|
|
|
|
|
|
|
-- incomplete, to avoid expensive book opening
|
|
|
|
|
|
|
|
book_props = stats
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Files opened after 20170701 have an accurate 'doc_pages' setting
|
|
|
|
|
|
|
|
local doc_pages = doc_settings:readSetting('doc_pages')
|
|
|
|
|
|
|
|
if doc_pages and book_props then
|
|
|
|
|
|
|
|
book_props.pages = doc_pages
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Files opened after 20170701 have an accurate 'doc_pages' setting
|
|
|
|
|
|
|
|
local doc_pages = doc_settings:readSetting('doc_pages')
|
|
|
|
|
|
|
|
if doc_pages and book_props then
|
|
|
|
|
|
|
|
book_props.pages = doc_pages
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|