Ensure "Open last/previous" point to existing files #4367
Merged
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.
In reader, after having opened doc1.html and doc2.html, being in doc2.html, going to History (where Delete on current book doc2.html is forbidden) and deleting doc1.html, we would still see in the top right menu:
Previous: doc1.html
, and taping on it would show the Opening dialog, an error, and KOReader would exit (UIManager: no widget left to show).This fixes this by ensuring we alway refresh the previous document in that menu item to the previous still existing document.
I also ensured it globally for any Delete from FileManager or History invoked from FileManager, to fix: Reading doc1.html > File browser > delete doc1.html > Exiting Koreader > Opening Koreader >
Cannot open last file. This could be because it was deleted or because external storage is still being mounted. Do you want to retry?
Deleted files still stay in History (for those that don't have the option to not do that enabled), they are just not candidates for the Open last/Open previous menu items.