Repository navigation
Keep copies out of the source, staging names out of the manifest, and job names inside the destination - #41
Conversation
Destinations were compared with the source by resolved path only. POSIX realpath keeps the typed case, so on a case-insensitive volume a destination naming the source in another case passed, and a destination folder that was a junction or symlink into the source passed too. Each staging file was then written beside its clip and promoted over it, and the job read Verified with nothing off the card. assert_safe_destinations now also compares by identity along each destination's existing ancestors, a per-directory guard refuses staging into any folder that is or is inside the source (the file fails, nothing is created), and the copy's last check covers the final name as well as the staging path, by resolved path and identity.
A source file named *.offloader-partial was copied like any other, under a final name that a later file's staging name could equal, so it could be truncated or deleted after being reported Verified. The scan now leaves such files out (casefolded) and reports each one as a job warning, without failing the job or adding a manifest entry; selections apply the same rule to source and final names. A file already at a staging name is never opened with wb or deleted: the copy is staged under the next free staging name and a warning names the file left alone.
The job name, from --name, the app's job name, the source folder's name or the volume label, was joined onto each destination as <name>_Reports unsanitized. A traversal or separator in it wrote reports outside the destination, and a colon or trailing dot failed on Windows. Both places a Job is built now pass the final name through naming.sanitize, and a typed name that changed gets a warning naming the one used.
choose_report_folder compared copied folder names with os.path.normcase, a no-op on POSIX and blind to Unicode composition everywhere, so a copied a001_Reports/ and a job named A001 shared one folder on APFS. It now uses _collision_key, which casefolds and NFC-normalizes on every platform.
The previous commit staged a copy under the next free staging name whenever a file was already at <name>.offloader-partial, and left that file alone. After a crash that strands a clip-sized leftover on the destination on every rerun, with nothing to clear it. No source file with the staging suffix is copied any more, so a file at a staging name is this tool's own leftover and the next copy of that file stages over it, as it always has. The one case that differs, a file an earlier version promoted under a staging name, is documented as a limit.
A fully verified job on a platform that cannot evict the page cache carries that warning, so the plain-job-name test checks for the absence of a job name warning instead of an empty list.
owenpkent
left a comment
There was a problem hiding this comment.
A valid sibling destination can be rejected before copying starts. I confirmed the difference between the merge base and 2b4852b with the Windows CLI. Four focused tests passed for staging files, explicit selection, job names, and report-folder collisions. All nine GitHub checks passed.
| Lexical ancestors of the absolute path, `..` and all, so a link part-way | ||
| up is examined as itself and as whatever it points at, via `stat`. | ||
| """ | ||
| absolute = Path(path).absolute() |
There was a problem hiding this comment.
[P2] Check the ancestors of the effective destination
For a source named card and a destination spelled card/../backup, Path.absolute().parents includes card even though the destination resolves to its sibling. The identity comparison then rejects a valid transfer. The Windows CLI copied the fixture and exited 0 on the merge base. This head exited 3 before creating the backup.
Build the ancestor chain from the effective path after resolving links and parent components, including any suffix that has yet to be created. Add a regression for the sibling spelling alongside the existing alias and nested-destination cases.
owenpkent
left a comment
There was a problem hiding this comment.
No new actionable findings at f38f7a3. The sibling-path regression is fixed. An explicitly selected file with a reserved source or delivery name now fails at every destination and stays in the manifest. Ordinary scans still exclude the reserved staging suffix as documented.
Eleven focused Windows tests passed for sibling paths, source aliases, destination identity, and explicit selections. All nine GitHub checks passed. The PR description still describes the previous warning-only behavior for explicit selections.
# Conflicts: # CHANGELOG.md
What
Four engine fixes, one commit each, plus one follow-up commit from review.
*.offloader-partialis never copied now. Each one is named in a job warning. It does not fail the job and gets no manifest entry. The rule lives inscan, so the copy,reportand the duplicate-card check see the same file list, and it applies to timeline selections too.--name, the app's job name, the source folder name and the volume label all go throughnaming.sanitizein the engine, with a warning when a typed name had to change.choose_report_foldernow uses the collision check's casefolded, NFC-normalized key.Behaviour to know about
Tests
New tests in
tests/test_data_safety.py, each run against the unfixedengine.pyand failing there, with two exceptions that are platform guards on Windows: the native case-variant test and the linked-destination test already pass here because Windows resolves case. They become real regression tests on the macOS runner.test_a_rerun_clears_the_staging_file_a_killed_run_leftis a guard for existing behaviour, not a failure proof.No existing test was modified.
Checked
ruff check src tests: clean--fuzz): 95 passed, 1 skipped