diff --git a/darkseid/comicarchive.py b/darkseid/comicarchive.py index f381b58..b36f426 100644 --- a/darkseid/comicarchive.py +++ b/darkseid/comicarchive.py @@ -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)) @@ -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(): diff --git a/tests/test_darkseid_comicarchive.py b/tests/test_darkseid_comicarchive.py index 9d35d3f..2e7fe42 100644 --- a/tests/test_darkseid_comicarchive.py +++ b/tests/test_darkseid_comicarchive.py @@ -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: