View Single Post
Old 01-04-2016, 07:28 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,377
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no easy way to do that. onimport is run in a separate process. A short lived worker process is used to read metadata from ebook files. postimport uns in the main process, which actually adds the files to the database.

The only way to pass information between onimport and postimport would be to persist the data in the filesystem. You could simply write the information keyed by file path to a temp file in onimport and read it from the temp file in onpostimport. There are two problems witht hat you would have to overcome:

1) Identifying the file. You would need to robustly identify the same file in the two contexts. Using the file path may or may not work, since other onimport plugins can change the file path.

2) On windows you will run into file locking issues when using a temp file. So remember to use the share_open() function from calibre.utils.shared_file
kovidgoyal is offline   Reply With Quote