View Single Post
Old 01-20-2018, 09:42 AM   #272
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,899
Karma: 207182180
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by BeckyEbook View Post
I need one more thing: how to detect (via the plugin) if the file has been modified but not saved (exist * after filename).
Quote:
Originally Posted by DiapDealer View Post
It's probably best to create modified flags for yourself in your plugin. Whether that's by setting flags whenever you know that your plugin has modified a file, or by gathering a list of some sort of file checksums before processing and then comparing those files checksums before exiting.

Plugins work on copies of files. Meaning changes aren't incorporated into the existing plugin until after the plugin completes.

There are some dictionaries in wrapper.py that can be accessed with that info, but that's considered bad form (somewhat) since unforeseen things can happen if those dictionary contents are accidentally modified incorrectly.
it occurs to me that I may have misunderstood your question. If you're asking if there's a way for plugins to know which of an epub's files are changed-but-unsaved before the plugin took control, I'm afraid the answer is no. Plugins simply get copies of an epub's contents in their current state. There is no regard whatsoever for whether or not the epub is in an unsaved state.

It occurs to me, however, that it may be a good idea for there to be such info passed to plugins. Maybe not at the individual file level, but I think there probably should be a way for a plugin to request/warn that an epub is in and unsaved state before continuing. I'm thinking of output/input plugins especially. With Kevin's new FolderOut plugin for instance, silently saving an OEBPS copy of an unsaved epub might cause unnecessary confusion.
DiapDealer is offline   Reply With Quote