Failure to rename files in ebook editor leads to corrupted ebook
calibre 2.71 64-bit / Windows 10
In some cases, an error might occur while trying to rename files in ebook editor.
If book is saved after getting the error (either it was in unsaved state, or if another modification is performed), book becomes corrupted.
1/ Open the provided sample epub file in ebook editor and try to rename a file, e.g. try to rename "start.xhtml" as something else. You get the following error message:
calibre, version 2.71.0
ERROR: Failed to rename files: Failed to rename files, click Show details for more information.
Traceback (most recent call last):
File "ntpath.py", line 528, in relpath
ValueError: path is on drive C:, start on drive E:
2/ After closing the error, make any modification, for example change some text.
3/ Save, and close the file.
4/ Reopen it: file that failed to be renamed in step #1 was in fact renamed ("on disk"), but not in the opf.
It is also possible to get the error while using the "polish books" function on the provided epub in the calibre library, with a similar error stack, but book is not corrupted.
Note: While the ebook was "error-free" before the rename operation, launching "Check Book" right after getting the error shows something is now wrong with it. So I think the error that occurs during the rename operation is not properly rolled back.
For the error to happen, I had to craft a "a" tag with some invalid (?) href (in the text.xhtml file).
The invalid URI is not detected by the "Check Book" function (flightcrew, epub check 3 and 4 detect it). I do not know if this error should be detected or not by calibre, but one thing is sure, the parsing that occurs while renaming shokes on it and blocks the rename operation, while checker does not.
- rename operation should not fail,
- if rename operation fails, ebook should not be corrupted
- may be this should be the subject of another ticked, but the initial error should have been detected, like other checker software.