View Single Post
Old 05-06-2023, 05:09 PM   #5
Leseratte_10
Groupie
Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.Leseratte_10 ought to be getting tired of karma fortunes by now.
 
Posts: 183
Karma: 3587000
Join Date: Sep 2021
Device: PB Era, PB InkPad 3 Pro
That looked like interesting options.

Unfortunately, the GetFileName plugin seems to be a bit unreliable, especially when there's multiple files involved with the same name (say I import /tmp/test1/file.acsm and /tmp/test2/file.acsm at the same time), but I will take a closer look tomorrow when I'm more awake (the fact that all comments and even all variable names are in spanish doesn't really make the code easy to read). And it also seems to be unreliable when combined with multiple FileTypePlugins, as mentioned in the last post(s) #401 and later in the thread.

I found a comment by Kovid Goyal about a cool attribute "self.original_path_to_file", which I thought was my exact solution, but unfortunately that attribute is only set during the "run" phase of the plugin - not during "postadd" ... maybe Calibre could be modded to set that property for the postadd phase as well.

But another question would be - even if this property is added, does the file still exist by then? Particularly when a file has been added through the Calibre server?

As for storing that information in the file - I could do that, but A) you'd never know if FileTypePlugins running after mine would keep that, and B) I'd like the original file to stay as close to the original as possible, so I'd rather not do that.

There's just no good way to match up information stored during the run() phase with information gathered during the postadd() phase, because there's no single unique identifier (for the book) that's available during both.

It would be cool if Calibre would assign a random unique UUID to a book file immediately when the import starts, and then made that UUID available to every single FileTypePlugin in every single execution step of the plugins that could be touching that file, so plugins could immediately identify "Okay, *this* is the exact same file I touched earlier".

Last edited by Leseratte_10; 05-06-2023 at 05:30 PM.
Leseratte_10 is offline   Reply With Quote