## Implementation Plan: Fix Zip Service 100% Failure Rate ### Scope Apply two missing fixes to `devplacepy/routers/projects/project_files.py` (primary file; actual path may be `devplacepy/project_files.py` or similar — adjust based on repo structure). Both changes originate from branches `origin/typosaurus/ticket-67` and `origin/typosaurus/ticket-68` (already on HEAD for ticket-68). Verify that `_guard_writable` removal is already present. ### Changes Required 1. **Resilience to missing blob files in `export_to_dir` and `_export_node`** - In `export_to_dir` (around line 709), wrap each `shutil.copyfile(src, dst)` call in a `try/except (FileNotFoundError, OSError)`. On exception, log a `logger.warning("Blob file missing: %s", src)` and `continue` (or skip the file). - Apply the same wrapper to `shutil.copyfile` in `_export_node` (around line 580). This method is also used by the fork service’s `sync_dir_bidirectional`. 2. **Clean up orphaned blobs in `delete_node`** - In `delete_node` (around line 466-470), after soft-deleting all descendant rows, iterate over any binary nodes (rows where `row.binary is True`) and call `_unlink_blob(row)`. This prevents future blob/Db mismatches. 3. **Remove `_guard_writable` from `export_to_dir`** (already on HEAD) - Confirm line 687 no longer contains a call to `_guard_writable(project_uid)`. If still present, delete it. Export is a read operation and must not be blocked by the project’s read-only flag. ### Execution Steps 1. Identify the exact file(s) containing `project_files.py`. Based on prior structure, the file is likely `devplacepy/routers/projects/project_files.py`. If not, locate via `grep -r "def export_to_dir"`. 2. Apply the three changes above as edits to that file. 3. Create a virtual environment to bypass PEP 668 restrictions: ```bash python3 -m venv .venv source .venv/bin/activate pip install -e '.[dev]' -q pip install -q ruff ``` 4. Run verification commands inside the venv: ```bash make test-unit ruff check . ``` ### Definition of Done - [ ] All three changes are applied to the source file(s) – no missing or partial fixes. - [ ] `git diff` or equivalent shows only the intended modifications. - [ ] Virtual environment created and dependencies installed without errors. - [ ] `make test-unit` exits with code 0 and all tests pass. - [ ] `ruff check .` exits with code 0 and reports no linting errors. - [ ] No merge conflicts exist in the working tree.