From c3f472e4ababafb3739b7dbf83656ba166512098 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 Jun 2012 16:25:52 +0530 Subject: [PATCH] EPUB Output: Fix a bug that could cause corrupted output when doing an EPUB/OEB to EPUB conversion if the input EPUB had multiple files with the same name --- src/calibre/ebooks/oeb/transforms/filenames.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/filenames.py b/src/calibre/ebooks/oeb/transforms/filenames.py index 00b71ea8be..ddf4def30c 100644 --- a/src/calibre/ebooks/oeb/transforms/filenames.py +++ b/src/calibre/ebooks/oeb/transforms/filenames.py @@ -105,14 +105,14 @@ class UniqueFilenames(object): # {{{ base, ext = posixpath.splitext(item.href) nhref = base + suffix + ext nhref = oeb.manifest.generate(href=nhref)[1] + spine_pos = item.spine_position + oeb.manifest.remove(item) nitem = oeb.manifest.add(item.id, nhref, item.media_type, data=data, fallback=item.fallback) self.seen_filenames.add(posixpath.basename(nhref)) self.rename_map[item.href] = nhref - if item.spine_position is not None: - oeb.spine.insert(item.spine_position, nitem, item.linear) - oeb.spine.remove(item) - oeb.manifest.remove(item) + if spine_pos is not None: + oeb.spine.insert(spine_pos, nitem, item.linear) else: self.seen_filenames.add(fname)