Skip to content

Commit

Permalink
Don't attempt to write metadata to .cbr
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple committed Jul 10, 2022
1 parent f18aaa6 commit 430f559
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions darkseid/comicarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class ComicArchive:
"""Comic Archive implementation"""

class ArchiveType:
"""Types of archives supported. Currently only .cbz and .cb7"""
"""Types of archives supported. Currently .cbr, .cbz, and .cb7"""

zip, sevenzip, rar, unknown = list(range(4))

Expand Down Expand Up @@ -438,7 +438,7 @@ def read_raw_metadata(self) -> Optional[str]:

def write_metadata(self, metadata: Optional[GenericMetadata]) -> bool:
"""Write the metadata to the archive"""
if metadata is None:
if metadata is None or not self.is_writable():
return False
self.apply_archive_info_to_metadata(metadata, calc_page_sizes=True)
if raw_cix := self.read_raw_metadata():
Expand Down
5 changes: 5 additions & 0 deletions tests/test_darkseid_comicarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ def test_archive_export_to_cb7(tmp_path, fake_cbz: ComicArchive) -> None:
#######
# CBR #
#######
@pytest.mark.skipif(sys.platform in ["win32", "darwin"], reason="Skip MacOS & Windows.")
def test_rar_write(fake_rar: ComicArchive, fake_metadata: GenericMetadata) -> None:
assert fake_rar.write_metadata(fake_metadata) is False


# Skip test for Windows and MacOS.
@pytest.mark.skipif(sys.platform in ["win32", "darwin"], reason="Skip MacOS & Windows.")
def test_rar_file_exists(fake_rar: ComicArchive) -> None:
Expand Down

0 comments on commit 430f559

Please sign in to comment.