fix(kc_format): eliminate duplicate silo/manifest.json in .kc files #311
Reference in New Issue
Block a user
Delete Branch "fix/kc-duplicate-manifest"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Every save produces a Python warning:
The
.kcZIP accumulates duplicatesilo/manifest.jsonentries on each save, growing the file over time.Root Cause
Two code paths in
kc_format.pyappendsilo/manifest.jsonwithout removing the previous entry:slotFinishSaveDocument()— re-injects the cached manifest fromentries, then themodified_atupdate branch writes a second copy viawritestrin append mode.update_manifest_fields()— opens the ZIP in append mode and writes an updated manifest without removing the old one.Fix
slotFinishSaveDocument(): Prepare the final manifest (with updatedmodified_at) in theentriesdict before writing to the ZIP, so only one copy is ever written.update_manifest_fields(): Rewrite the ZIP atomically via a temp file, deduplicating any pre-existing duplicate entries in the process.Testing
.kcdocumentDuplicate name: 'silo/manifest.json'warning in the consolepython3 -c "import zipfile; print(zipfile.ZipFile('file.kc').namelist())"— should showsilo/manifest.jsonexactly oncemodified_at,part_uuid, etc.)