mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Kobo driver: Sideloaded kepubs not added from device properly
When a sideloaded kepub is added from a Kobo device to the calibre library, it is added as an epub, but the file copied is corrupt. Fixes #1221035 [Sideloaded kepubs not added to library correctly](https://bugs.launchpad.net/calibre/+bug/1221035)
This commit is contained in:
parent
80887a8a14
commit
0aeec73eae
@ -13,7 +13,7 @@ Originally developed by Timothy Legge <timlegge@gmail.com>.
|
||||
Extended to support Touch firmware 2.0.0 and later and newer devices by David Forrester <davidfor@internode.on.net>
|
||||
'''
|
||||
|
||||
import os, time
|
||||
import os, time, shutil
|
||||
|
||||
from contextlib import closing
|
||||
from calibre.devices.usbms.books import BookList
|
||||
@ -1001,9 +1001,10 @@ class KOBO(USBMS):
|
||||
'''
|
||||
for idx, path in enumerate(paths):
|
||||
if path.find('kepub') >= 0:
|
||||
with closing(open(path)) as r:
|
||||
with closing(open(path, 'rb')) as r:
|
||||
tf = PersistentTemporaryFile(suffix='.epub')
|
||||
tf.write(r.read())
|
||||
shutil.copyfileobj(r, tf)
|
||||
# tf.write(r.read())
|
||||
paths[idx] = tf.name
|
||||
return paths
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user