From 87dd29e97fa5bd71448e94a7af0bcef6f82bdb8d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 14 Dec 2013 08:47:27 +0530 Subject: [PATCH] Edit book: Fix replacing a file with another file with exactly the same filename causing an error. Fixes #1260822 [Cover replacement in edit fails](https://bugs.launchpad.net/calibre/+bug/1260822) --- src/calibre/ebooks/oeb/polish/replace.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/replace.py b/src/calibre/ebooks/oeb/polish/replace.py index aafa08ba6f..4f4e74f39e 100644 --- a/src/calibre/ebooks/oeb/polish/replace.py +++ b/src/calibre/ebooks/oeb/polish/replace.py @@ -137,10 +137,10 @@ def replace_file(container, name, path, basename, force_mt=None): nname = b + ('_%d.%s' % (count, e)) rename_files(container, {name:nname}) mt = force_mt or container.guess_type(nname) - for itemid, q in container.manifest_id_map.iteritems(): - if q == nname: - for item in container.opf_xpath('//opf:manifest/opf:item[@href and @id="%s"]' % itemid): - item.set('media-type', mt) + for itemid, q in container.manifest_id_map.iteritems(): + if q == nname: + for item in container.opf_xpath('//opf:manifest/opf:item[@href and @id="%s"]' % itemid): + item.set('media-type', mt) container.dirty(container.opf_name) with container.open(nname, 'wb') as dest: shutil.copyfileobj(src, dest)