fix zipseq ignoring zip metadata and not replacing with 7z
This commit is contained in:
@@ -649,16 +649,17 @@ def run_zip(requested_workers: int | None, *, verbose: bool) -> int:
|
||||
|
||||
# Check if we need to upgrade from .zip to .7z
|
||||
old_zip_path = None
|
||||
old_stored_state = None
|
||||
if ZIPPER_TYPE == "7z":
|
||||
old_zip_path = zip_path.with_suffix(".zip")
|
||||
if old_zip_path.exists():
|
||||
old_state_path = state_path_for(old_zip_path)
|
||||
old_stored_state = load_state(old_state_path)
|
||||
# If old .zip exists and archive doesn't, we'll check state later
|
||||
# If old .zip exists and .7z doesn't, use old .zip's state for comparison
|
||||
if not zip_path.exists() and old_stored_state is not None:
|
||||
stored_state = old_stored_state
|
||||
|
||||
# If archive exists and we have stored state, do quick check before computing full state
|
||||
# If .7z archive exists and we have stored state, do quick check before computing full state
|
||||
if zip_path.exists() and stored_state is not None:
|
||||
# Quick check: if directory mtime is older than archive, likely unchanged
|
||||
try:
|
||||
@@ -666,7 +667,7 @@ def run_zip(requested_workers: int | None, *, verbose: bool) -> int:
|
||||
archive_mtime = zip_path.stat().st_mtime_ns
|
||||
# If directory wasn't modified since archive was created, skip state computation
|
||||
if dir_mtime <= archive_mtime:
|
||||
# Still need to check for old .zip cleanup
|
||||
# Still need to check for old .zip cleanup (we have .7z, so .zip is obsolete)
|
||||
if old_zip_path and old_zip_path.exists():
|
||||
old_zip_path.unlink(missing_ok=True)
|
||||
old_state_path = state_path_for(old_zip_path)
|
||||
@@ -684,13 +685,21 @@ def run_zip(requested_workers: int | None, *, verbose: bool) -> int:
|
||||
|
||||
# Check if state changed
|
||||
if stored_state is not None and not state_changed(seq_state, stored_state):
|
||||
# Target archive is up to date, but we might still need to clean up old .zip
|
||||
if old_zip_path and old_zip_path.exists():
|
||||
old_zip_path.unlink(missing_ok=True)
|
||||
old_state_path = state_path_for(old_zip_path)
|
||||
if old_state_path.exists():
|
||||
old_state_path.unlink(missing_ok=True)
|
||||
continue
|
||||
# Metadata matches stored state
|
||||
if zip_path.exists():
|
||||
# .7z exists and is up to date, clean up old .zip if it exists
|
||||
if old_zip_path and old_zip_path.exists():
|
||||
old_zip_path.unlink(missing_ok=True)
|
||||
old_state_path = state_path_for(old_zip_path)
|
||||
if old_state_path.exists():
|
||||
old_state_path.unlink(missing_ok=True)
|
||||
elif old_zip_path and old_zip_path.exists() and old_stored_state is not None:
|
||||
# .7z doesn't exist, but .zip exists and metadata matches
|
||||
# Keep the .zip file, don't create .7z
|
||||
continue
|
||||
else:
|
||||
# No archive exists, but state matches (shouldn't happen, but be safe)
|
||||
continue
|
||||
|
||||
work_items.append((seq_dir, zip_path, state_path, seq_state))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user