View Single Post
Old 09-04-2021, 03:00 PM   #1
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
Cancel book import from inside a FileTypePlugin

Hello,

is there a way for a Calibre FileTypePlugin to completely abort importing the current book (and ideally return an error message to the user)?

If I have a FileTypePlugin that's supposed to parse a custom file type and convert that into a format that Calibre understands, I'd like to be able to be like "Okay, this file the user is trying to import *is* in my custom file format (so don't try other file import plugins), but it's damaged / corrupted or otherwise unsuitable to use (so also don't import it into the database).

When I just return the original unmodified file path, or when I throw an Exception in the "run" function of my plugin class, Calibre just hands that book down to the next FileTypePlugin in line, or if there is none, imports it as-is. That results in an unusable book entry in Calibre that the user has to manually delete again.

Is there a way I can convey to calibre that the file is broken and to stop importing it and instead display a custom error message to the user?

I have read the plugin documentation and the plugin creation guide but I was unable to find that functionality in there.

Is that hidden somewhere, or is that something that Calibre doesn't support?
Leseratte_10 is offline   Reply With Quote