Rearrange the lines in delete_file.
If anything is going to raise an exception here I expect it to be the item missing from the manifest. In which case let's get that out of the way early and only delete from disk at the very end.
This commit is contained in:
parent
fd73ecfe2e
commit
6386f25cd4
1 changed files with 3 additions and 3 deletions
|
@ -479,12 +479,12 @@ class Epub:
|
|||
)
|
||||
|
||||
def delete_file(self, id):
|
||||
os.remove(self.get_filepath(id).absolute_path)
|
||||
manifest_item = self.opf.manifest.find('item', {'id': id})
|
||||
manifest_item.extract()
|
||||
spine_item = self.opf.spine.find('itemref', {'idref': id})
|
||||
if spine_item:
|
||||
spine_item.extract()
|
||||
manifest_item = self.opf.manifest.find('item', {'id': id})
|
||||
manifest_item.extract()
|
||||
os.remove(self.get_filepath(id).absolute_path)
|
||||
|
||||
def get_filepath(self, id):
|
||||
href = self.opf.manifest.find('item', {'id': id})['href']
|
||||
|
|
Loading…
Reference in a new issue