Skip to content

Commit

Permalink
Remove *all* metadata from comic (#117)
Browse files Browse the repository at this point in the history
Prior code didn't check any subfolders for metadata.
  • Loading branch information
bpepple authored Sep 10, 2024
1 parent 8c54d72 commit d3dd2d0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions darkseid/comic.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ def remove_metadata(self: Comic) -> bool:
"""

if self.has_metadata():
write_success = self._archiver.remove_file(self._ci_xml_filename)
metadata_files = [
path
for path in self._archiver.get_filename_list()
if Path(path).name.lower() == self._ci_xml_filename.lower()
]
write_success = self._archiver.remove_files(metadata_files)
return self._successful_write(write_success, False, None)
return True

Expand Down Expand Up @@ -377,6 +382,11 @@ def _successful_write(
self.reset_cache()
return write_success

def _check_for_metadata(self: Comic) -> bool:
target_filename = self._ci_xml_filename.lower()
filenames = {Path(path).name.lower() for path in self._archiver.get_filename_list()}
return target_filename in filenames

def has_metadata(self: Comic) -> bool:
"""
Checks to see if the archive has metadata.
Expand All @@ -386,13 +396,7 @@ def has_metadata(self: Comic) -> bool:
"""

if self._has_md is None:
self._has_md = bool(
self.seems_to_be_a_comic_archive()
and (
not self.seems_to_be_a_comic_archive()
or self._ci_xml_filename in self._archiver.get_filename_list()
),
)
self._has_md = self.seems_to_be_a_comic_archive() and self._check_for_metadata()

return self._has_md

Expand Down

0 comments on commit d3dd2d0

Please sign in to comment.