fix zipseq ignoring zip metadata and not replacing with 7z

This commit is contained in:
Nathan
2025-11-11 12:45:44 -07:00
parent a152d17136
commit 55a2074c62
2 changed files with 221 additions and 13 deletions

View File

@@ -19134,7 +19134,6 @@ _**Agent (model default, mode Agent)**_
---
The issue: `UpdateSequences.bat` is in `Renders\04 Securing Your Seam\`, so going up one level (`%script_dir%..`) gives `Renders\` instead of the project root. Checking the batch file logic:
@@ -19160,7 +19159,6 @@ The issue: `UpdateSequences.bat` is in `Renders\04 Securing Your Seam\`, so goin
---
The issue: `UpdateSequences.bat` is in `Renders\04 Securing Your Seam\`, so going up one level (`..`) gives `Renders\` instead of the project root. `ZipSeqArchv.bat` works because it's directly in `Renders\`. Updating `UpdateSequences.bat` to go up two levels to reach the project root:
@@ -19193,7 +19191,6 @@ Lines added: 1, lines removed: 1
---
Fixed. `UpdateSequences.bat` is in subdirectories like `Renders\04 Securing Your Seam\`, so it needs to go up two levels to reach the project root, not one.
The script now goes up two levels (`..\..`) to find `P:\250827_FestivalTurf\.config\config.json`.
@@ -19202,3 +19199,205 @@ Redeploy with `ConfigLoader.ps1` to update all `UpdateSequences.bat` files in th
---
_**User (2025-11-11 19:15Z)**_
@2025-11-11_01-50Z-update-configloader-to-overwrite-gitattributes-and-gitignore.md we pulled some changes from home. the zipper is removing all non-7z archives, but it's not replacing them with new 7z archives. We need the zips to be kept if their metadata is still consistent, and only replaced with 7z if the metadata are not consistent.
---
_**Agent (model default, mode Agent)**_
---
---
Checking the upgrade logic from `.zip` to `.7z` to ensure `.zip` files are only replaced when metadata changes:
---
<tool-use data-tool-type="read" data-tool-name="read_file">
<details><summary>Tool use: **read_file** • Read file: zip_sequences.py</summary>
</details>
</tool-use>
---
---
Checking the `zip_sequence` function for `.zip` deletion logic:
---
<tool-use data-tool-type="read" data-tool-name="read_file">
<details><summary>Tool use: **read_file** • Read file: zip_sequences.py</summary>
</details>
</tool-use>
---
---
Fixing the logic: when a `.zip` exists, `.7z` doesn't, and metadata matches, keep the `.zip` and don't create a `.7z`. Updating the code:
---
<tool-use data-tool-type="read" data-tool-name="read_file">
<details><summary>Tool use: **read_file** • Read file: zip_sequences.py</summary>
</details>
</tool-use>
---
---
Fixing the logic: when a `.zip` exists, `.7z` doesn't, and metadata matches, keep the `.zip` and don't create a `.7z`. Updating the code:
---
<tool-use data-tool-type="write" data-tool-name="search_replace">
<details><summary>Tool use: **code_edit** • Edit file: zip_sequences.py</summary>
**Chunk 1**
Lines added: 3, lines removed: 2
```diff
@@ -650,14 +650,15 @@
# Check if we need to upgrade from .zip to .7z
old_zip_path = None
+ old_stored_state = None
if ZIPPER_TYPE == &quot;7z&quot;:
old_zip_path = zip_path.with_suffix(&quot;.zip&quot;)
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&#39;t, we&#39;ll check state later
+ # If old .zip exists and .7z doesn&#39;t, use old .zip&#39;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
```
**Chunk 2**
Lines added: 1, lines removed: 1
```diff
@@ -667,5 +668,5 @@
# If directory wasn&#39;t modified since archive was created, skip state computation
if dir_mtime &lt;= 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)
```
**Chunk 3**
Lines added: 15, lines removed: 7
```diff
@@ -685,11 +686,19 @@
# 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&#39;t exist, but .zip exists and metadata matches
+ # Keep the .zip file, don&#39;t create .7z
+ continue
+ else:
+ # No archive exists, but state matches (shouldn&#39;t happen, but be safe)
+ continue
work_items.append((seq_dir, zip_path, state_path, seq_state))
```
</details>
</tool-use>
---
---
Checking for linting errors:
---
<tool-use data-tool-type="generic" data-tool-name="read_lints">
<details>
<summary>Tool use: **read_lints** • Read lints for 1 file</summary>
Lint paths:
- `zip_sequences.py`
Lint results
**No lint errors found**
</details>
</tool-use>
---
---
Fixed the logic. The script now:
1. **Keeps `.zip` files when metadata matches**: If a `.zip` exists, no `.7z` exists, and the metadata matches the current state, it keeps the `.zip` and does not create a `.7z`.
2. **Only replaces `.zip` with `.7z` when metadata changes**: If the metadata doesn't match (files have changed), it creates a new `.7z` and deletes the old `.zip`.
3. **Cleans up obsolete `.zip` files**: If a `.7z` already exists and is up-to-date, it deletes any old `.zip` files.
The key change is on lines 696-699: when a `.zip` exists, no `.7z` exists, and the metadata matches, the script skips creating a `.7z` and keeps the `.zip` file.
This ensures that `.zip` files are only replaced with `.7z` when the files have actually changed, not just because the script is running.
---

View File

@@ -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))