From b561a3233f8aceaa89c4635f9b358c2cfcc490f3 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 26 Aug 2020 17:58:10 -0700 Subject: [PATCH] Fix delete_item calling get_filepath after extract from manifest. --- epubfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epubfile.py b/epubfile.py index e4be293..ecaaa7b 100644 --- a/epubfile.py +++ b/epubfile.py @@ -617,11 +617,13 @@ class Epub: @writes def delete_file(self, id): manifest_item = self.opf.manifest.find('item', {'id': id}) + filepath = self.get_filepath(id) + manifest_item.extract() spine_item = self.opf.spine.find('itemref', {'idref': id}) if spine_item: spine_item.extract() - os.remove(self.get_filepath(id).absolute_path) + os.remove(filepath.absolute_path) def get_filepath(self, id): href = self.opf.manifest.find('item', {'id': id})['href']