mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
c91c1aeba2
commit
d9b75ef819
@ -373,7 +373,11 @@ class Container(object):
|
||||
def open(self, name, mode='rb'):
|
||||
if name in self.dirtied:
|
||||
self.commit_item(name)
|
||||
return open(self.name_to_abspath(name), mode)
|
||||
path = self.name_to_abspath(name)
|
||||
base = os.path.dirname(path)
|
||||
if not os.path.exists(base):
|
||||
os.makedirs(base)
|
||||
return open(path, mode)
|
||||
|
||||
def commit(self, outpath=None):
|
||||
for name in tuple(self.dirtied):
|
||||
|
@ -27,7 +27,8 @@ def set_azw3_cover(container, cover_path, report):
|
||||
guide = container.opf_xpath('//opf:guide')[0]
|
||||
container.insert_into_xml(guide, guide.makeelement(
|
||||
OPF('reference'), href=href, type='cover'))
|
||||
shutil.copyfile(cover_path, container.name_to_abspath(name))
|
||||
with open(cover_path, 'rb') as src, container.open(name, 'wb') as dest:
|
||||
shutil.copyfileobj(src, dest)
|
||||
container.dirty(container.opf_name)
|
||||
report('Cover updated' if found else 'Cover inserted')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user