diff --git a/comicinfoxml.py b/comicinfoxml.py index 0d93204..99a51f5 100644 --- a/comicinfoxml.py +++ b/comicinfoxml.py @@ -124,7 +124,10 @@ def get_metadata_string(self, archive: Archiver) -> str: def set_metadata(self, metadata: GenericMetadata, archive: Archiver) -> bool: if self.supports_metadata(archive): - return archive.write_file(self.file, self._bytes_from_metadata(metadata, archive.read_file(self.file))) + xml = b'' + if self.has_metadata(archive): + xml = archive.read_file(self.file) + return archive.write_file(self.file, self._bytes_from_metadata(metadata, xml)) logger.warning('Archive (%s) does not support %s metadata', archive.name(), self.name()) return False