Fix crash and History with books in read-only directories #4138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
docsettings can be stored either as a sidecar file (prefered, when possible), or as a .lua file in the koreader/history/ folder (good, when book is in a read-only directory where we can't create the
.sdr/ directory).
They are managed correctly if for some reason, the book directory becomes writable: the docsettings in history/ is read, used, and removed when a docsetting in a .sdr/ can be saved.
These docsettings in koreader/history/ contribute to the History list build: they are put it in history.lua, and the duplicates on next history.lua builds are removed.
This fix a crash when a book is in a read-only directory. Closes #3869.
I verified that I can now open on Android books stored on the external SDCard, and the docsetting is saved in koreader/history/ . Closes #3365. Closes #3483.
Also fix History containing strange entries like "Book.epub.lua", that came from the koreader/history/book.epub.lua.old backup, that weren't removed as they are not a duplicate. Closes #4118.