mirror of
https://github.com/koreader/koreader.git
synced 2025-12-24 12:14:05 +01:00
Avoid writting highlights into read-only PDFs (#5889)
This commit is contained in:
@@ -175,6 +175,14 @@ function PdfDocument:saveHighlight(pageno, item)
|
||||
local suffix = util.getFileNameSuffix(self.file)
|
||||
if string.lower(suffix) ~= "pdf" then return end
|
||||
|
||||
if self.is_writable == nil then
|
||||
local handle = io.open(self.file, 'r+b')
|
||||
self.is_writable = handle ~= nil
|
||||
if handle then handle:close() end
|
||||
end
|
||||
if self.is_writable == false then
|
||||
return false
|
||||
end
|
||||
self.is_edited = true
|
||||
-- will also need mupdf_h.lua to be evaluated once
|
||||
-- but this is guaranteed at this point
|
||||
|
||||
Reference in New Issue
Block a user