Quote:
Originally Posted by cryzed
Hm, it's kind of hard to do since the file writing/updating for Calibre jobs seemingly works in a pretty complicated fashion -- workers get a target path that is supposed to be written to, but from that I don't think I can easily recreate the final path, so a custom backup path would have to be specified. However, even then, the file behind the outfilename that arrives in BaseStoryWriter.write_story() seems to be empty when the story is fully updated -- so one would have to change the code in all places where this method is called (3 places for the plugin).
Maybe Jimm can chime in with the best approach, I'm probably overlooking something obvious since I'm largely unfamiliar with the Calibre Plugin API.
|
That to me says you are taking the backup at the wrong time. The chapter gathering has already determined what has changed. From that, you should be able to do the backup before the download starts and access the original file.
But, calibre already has a backup method built in. It is probably possible to trigger the creation of the ORIGINAL_xxx that can be created when doing a conversion. Doing that has the advantage that calibre is expecting these files. And it is easy to restore them or use the editor to compare them.
And, the code to do this doesn't look hard. It is in gui2/tools.py, method convert_single_ebook. That does need access to the database, so it probably needs to be done before the download job is started.