View Single Post
Old 06-22-2011, 02:08 PM   #10
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
1) The temp file will last as long as calibre is open and it is unique (i.e. you own it) so you can delete it whenever you like.

3) Use as_file=True when calling format(). This copies the file into a SpooledTemporaryFile (which keep the entire contents of the file in memory unless the file is larger than 30MB in which case it is copied). Or I can add a method to db to compute hashes, if you send me an implementation of the method. Either is fine by me.

4) Does it really matter? Use as_file again. The vast majority of epubs are well under 30MB. This is assuming quality check runs in the main process. If it runs in a sub process, then you can change it to have two stages, one which runs in the main process and copies the files out and the second which unzips them and does the checking. This is how save to disk/bulk convert work in calibre.

5) I'm not implying that this is the only solution, just that it is the only solution I can think of. If you have other suggestions, I am happy to hear them.

Remember that most ebook files are a few MB and copying those around on a disk takes well under a second.

Last edited by kovidgoyal; 06-22-2011 at 02:11 PM.
kovidgoyal is offline   Reply With Quote