epubcheck
epubcheck copied to clipboard
Checking with "-mode exp" might overwrite existing epub-file
Let me describe what I did to explain the "problem":
Sometimes changes have to be done in an epub-file. So I take the epub-file and unzip it to a folder of it's name. I actually have a droplet either packing a folder as an epub or unpack it if it's an epub-file.
MyAwesomeEBook.epub
unzip MyAwesomeEBook.epub -d MyAwesomeEbook
When I've done my changes and run the epubchecker on the unpacked epub-data, it creates an epub-file in the first place. Unfortunately it creates an epub-file in the folder containing the unpacked-epub-data-folder with the name of the unpacked-epub-data-folder. As it doesn't check, if the file exists, it simply overwrites my original epub, checks it and deletes it afterwards.
java -jar epubcheck-3.0.1.jar -mode exp path/to/epub/MyAwesomeEBook
I suggest to create the temporary epub in a temporary directory or at least do a check, if the file already exists, output a warning and stop.
Last but not least: Thanks for this useful tool to automatically check epubs. Would be horrible to manually do it!
Regards, Felix
I would say EpubCheck is not in charge of actually building the Epub, just to check it, which is a full time job. You would have to write the scripts/programms to do the rest of the job.. I personnaly rename the folder before re-creating the Epub, so the original remains untouched. I don't even use anymore the "-mode exp" facility, but zip the folder myself, as part of the script.
What I want to point out is that this feature, as it exists, does what I described, which is, in my opinion, a problematic behavior.
I don't argue pro or contra the feature. As long as it exists, it should work properly.
Hi Felix, thanks for reporting this. As we've already discussed, I totally understand your point of view and will see if we find a solution for the upcoming 3.0.2 release.
Building in temp dir for -mode exp
would be the appropriate way. Then we would only need a way to save teh epub file when -save
flag is used.
Probably by adding a -1
to the name?
java -jar epubcheck-3.0.1.jar -mode exp -save path/to/epub/MyAwesomeEBook
would save the file as MyAwesomeEBook.epub
if the file doesn't exist yet and as MyAwesomeEBook-1.epub
if the file MyAwesomeEBook.epub
exists.
Would that be a solution?
Hi,
I'm fine with that.
Thanks for your effort, Regards, Felix
See also issue to #352 (if the -exp mode doesn't create a ZIP by default, there's no risk of "silent" file overwrite).