mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-04 05:25:05 +01:00
Fix #1047691 (Drag n drop to Book detail failure)
This commit is contained in:
parent
3b989ae2a6
commit
0a3f368280
1 changed files with 3 additions and 0 deletions
|
|
@ -1432,6 +1432,7 @@ def add_format(self, index, format, stream, index_is_id=False, path=None,
|
|||
pdir = os.path.dirname(dest)
|
||||
if not os.path.exists(pdir):
|
||||
os.makedirs(pdir)
|
||||
size = 0
|
||||
if copy_function is not None:
|
||||
copy_function(dest)
|
||||
size = os.path.getsize(dest)
|
||||
|
|
@ -1441,6 +1442,8 @@ def add_format(self, index, format, stream, index_is_id=False, path=None,
|
|||
with lopen(dest, 'wb') as f:
|
||||
shutil.copyfileobj(stream, f)
|
||||
size = f.tell()
|
||||
elif os.path.exists(dest):
|
||||
size = os.path.getsize(dest)
|
||||
self.conn.execute('INSERT OR REPLACE INTO data (book,format,uncompressed_size,name) VALUES (?,?,?,?)',
|
||||
(id, format.upper(), size, name))
|
||||
self.update_last_modified([id], commit=False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue