- if 'epub' in formats and book.epub_file:
- filename = book.epub_file.path
- archive.write(filename, str('%s.epub' % book.slug))
+ if book.root_ancestor not in already and 'epub' in formats and book.root_ancestor.epub_file:
+ filename = book.root_ancestor.epub_file.path
+ archive.write(filename, str('%s.epub' % book.root_ancestor.slug))
+ already.add(book.root_ancestor)