mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #791806 (Metadata causes freeze)
This commit is contained in:
parent
c460bcc30d
commit
facae420cb
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
The database used to store ebook metadata
|
The database used to store ebook metadata
|
||||||
'''
|
'''
|
||||||
import os, sys, shutil, cStringIO, glob, time, functools, traceback, re, \
|
import os, sys, shutil, cStringIO, glob, time, functools, traceback, re, \
|
||||||
json, uuid
|
json, uuid, tempfile
|
||||||
import threading, random
|
import threading, random
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
from math import ceil
|
from math import ceil
|
||||||
@ -591,11 +591,13 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
f.write(cdata)
|
f.write(cdata)
|
||||||
for format in formats:
|
for format in formats:
|
||||||
# Get data as string (can't use file as source and target files may be the same)
|
# Get data as string (can't use file as source and target files may be the same)
|
||||||
f = self.format(id, format, index_is_id=True, as_file=False)
|
f = self.format(id, format, index_is_id=True, as_file=True)
|
||||||
if not f:
|
if f is None:
|
||||||
continue
|
continue
|
||||||
stream = cStringIO.StringIO(f)
|
with tempfile.SpooledTemporaryFile(max_size=100*(1024**2)) as stream:
|
||||||
self.add_format(id, format, stream, index_is_id=True,
|
shutil.copyfileobj(f, stream)
|
||||||
|
stream.seek(0)
|
||||||
|
self.add_format(id, format, stream, index_is_id=True,
|
||||||
path=tpath, notify=False)
|
path=tpath, notify=False)
|
||||||
self.conn.execute('UPDATE books SET path=? WHERE id=?', (path, id))
|
self.conn.execute('UPDATE books SET path=? WHERE id=?', (path, id))
|
||||||
self.dirtied([id], commit=False)
|
self.dirtied([id], commit=False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user