From fa1fdd0dd2924bc1d4a74c1319f2b07f2b4b3d1f Mon Sep 17 00:00:00 2001 From: Brian Pepple Date: Thu, 29 Feb 2024 09:07:13 -0500 Subject: [PATCH] Fix Zipfile writing on Windows (#79) * Fix writing to zipfiles on Windows. --- .idea/darkseid.iml | 2 +- darkseid/archivers/zip.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.idea/darkseid.iml b/.idea/darkseid.iml index 5fdd65b..96045dc 100644 --- a/.idea/darkseid.iml +++ b/.idea/darkseid.iml @@ -2,7 +2,7 @@ - + diff --git a/darkseid/archivers/zip.py b/darkseid/archivers/zip.py index 3bce7a2..eee5df4 100644 --- a/darkseid/archivers/zip.py +++ b/darkseid/archivers/zip.py @@ -94,7 +94,8 @@ def _rebuild(self: "ZipArchiver", exclude_list: list[str]) -> bool: zout.writestr(item, buffer) # replace with the new file - self.path.unlink() + self.path.unlink(missing_ok=True) + zout.close() # Required on Windows shutil.move(cast(str, zout.filename), self.path) return True except (zipfile.BadZipfile, OSError) as e: