Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ project uses [semantic versioning][semver].
- **A folder marker in a failed run's manifest could never be superseded.** A
rerun lists the files inside a folder that could not be listed, never the
folder, so the marker kept failing `verify`. A newer manifest now supersedes
it when it lists at least one hashed file under the folder and everything it
lists there matched.
it when it lists at least one hashed file under the folder, everything it
lists there matched, and both manifests name the same job.

- **`--verify none` read "Copied" for a run that copied nothing.** An empty
source, or a rerun where every file was skipped on size alone, exited `0`.
Under `none`, "Copied" now needs at least one file actually copied; the rest
are Incomplete (exit `4`), as in the verified modes.
Under `none`, "Copied" now needs every file actually copied and at least
one file in the job; an empty source, or any file skipped on size alone,
reads Incomplete (exit `4`), as in the verified modes.

- **An infinite retry wait was never capped.** `Infinity` or `1e999` in
presets.json, or a delay times backoff that overflowed, survived the clamp
Expand Down Expand Up @@ -208,7 +209,9 @@ project uses [semantic versioning][semver].
The files it could not read stay unhashed in it, so `verify` failed until the
operator deleted it by hand. An unhashed entry is now superseded when a newer
manifest for the same destination root lists the same path with a hash that
matches; it is printed as `superseded by <manifest>`. Only that direction:
matches and both entries record the same source size and modification date
(see the first entry above); it is printed as `superseded by <manifest>`.
Only that direction:
a hashed entry is never superseded, so a copy corrupted since still fails.
Newer means the manifest's own recorded time, then its number
(`<name>_Reports-2`, `JobReport-2.mhl`), never the file's modification time.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pip install -e ".[dev]"
`ffmpeg` and `ffprobe` on `PATH` are optional — the suite runs without them.

```sh
pytest # 916 tests, about 20s
pytest # 1301 tests, about 20s
pytest --fuzz # property tests at 3000 examples each, about 3 min
ruff check src tests
pytest --cov=offloader --cov-report=term-missing
Expand Down
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ Exit status for `offload` (and, where they apply, `resolve`, `report` and

| Code | Meaning |
| --- | --- |
| `0` | Verified (or Copied under `--verify none`), and every report was written |
| `0` | Verified, or Copied under `--verify none` with every file copied, and every report was written |
| `1` | failed: a copy, verify or scan failure (a file failed, or a source folder could not be listed) |
| `2` | error: usage, environment (such as a missing timeline adapter) or an unreadable manifest; nothing was attempted |
| `3` | refused: an unsafe destination or control file; nothing was copied |
| `4` | incomplete: nothing failed, but not everything asked for was verified (unresolved timeline references, an empty source, files skipped by `--skip-existing` and checked by size only) |
| `4` | incomplete: nothing failed, but not everything asked for was verified or copied (unresolved timeline references, an empty source, any file skipped by `--skip-existing` and checked by size only), in every `--verify` mode including `none` |
| `5` | the copies verified but a report or manifest could not be written |
| `130` | cancelled: Ctrl+C or a control-file cancel |

`report` exits `5` when a report could not be written and `0` otherwise.
`report` exits `1` when its verdict is Failed (a failed or missing destination
file, a source folder that could not be listed, a skipped link), `5` when a
report could not be written, and `0` otherwise.

### Pausing a running job

Expand Down Expand Up @@ -217,8 +219,9 @@ checksums and reports as a card.

Every reference gets one status: `present`, `substituted`, `gap`, `ambiguous`,
`missing`, `offline`, `unsupported`, `external` or `generated`. Only `gap` is
copied. While anything is unresolved (every status but `present`, `gap` and
`generated`, plus a proxy whose frame counts could not be checked), `resolve`
copied. While anything is unresolved (`ambiguous`, `missing`, `offline`,
`unsupported` or `external`, or a `substituted` proxy whose frame counts could
not be checked), `resolve`
exits 4 and `offload` copies the gaps, lists what it could not supply in the
terminal and every report, calls the job `Incomplete` and exits 4. See
[docs/timeline.md](docs/timeline.md).
Expand Down Expand Up @@ -253,17 +256,25 @@ could be taken), so a destination missing a clip fails here; every manifest
under the folder is checked, earlier runs' included. An entry a failed run could
not hash is reported as superseded, and stops failing, once a newer manifest for
the same destination lists that file with a hash that still matches and the
same source size and modification date; a hashed entry is never superseded. See
same source size and modification date; a hashed entry is never superseded. An
entry that records neither a size nor a date (a file a cancelled job never
reached, or a folder that could not be listed) is superseded only by a newer
manifest naming the same job, so cancelling a job and running it again leaves
the folder passing. See
[`docs/data-safety.md`](docs/data-safety.md#a-manifest-lists-what-did-not-arrive).
Given a folder, an entry pointing outside it fails as `OUTSIDE` and is not read;
name the manifest file to verify it wherever its paths point.
`--allow-cache` skips the page-cache eviction: faster, and may verify memory
rather than the device.

For an ASC MHL history it also recomputes the directory content and structure
hashes, which is the only check that catches a rename or a moved file, every
file involved still hashes exactly as recorded. See
[`docs/ascmhl.md`](docs/ascmhl.md#directory-hashes).
An ASC MHL history is verified as one view across all its generations, each
path judged by the latest generation that lists it. Its directory content and
structure hashes are recomputed too, so a renamed or moved file shows as a
missing listed file with the directories above it changed, and the new name is
listed as not in the manifest. See
[`docs/ascmhl.md`](docs/ascmhl.md#directory-hashes). `verify` does not yet
compare the generations with the chain file: a replaced or missing generation
is reported when the next one is written, not here.

### Verification modes

Expand Down Expand Up @@ -295,7 +306,8 @@ which is why it is opt-in. See
- **CSV**: one row per source/destination pair, with checksums, media
metadata, the slate from whichever department wrote it (camera or sound), and
status. For spreadsheets and ingest scripts. A text cell that begins with
`=`, `+`, `-`, `@`, a tab or a carriage return (a filename off a card can)
`=`, `+`, `-`, `@`, a tab, a carriage return, a line feed, or the full-width
forms of `=`, `+`, `-` and `@` (a filename off a card can)
is written with a leading apostrophe so a spreadsheet shows it as text
instead of running it as a formula; a script reading the CSV will see that
apostrophe. Numbers and the header row are unchanged.
Expand Down Expand Up @@ -635,13 +647,13 @@ Full verification only when every present destination was hashed.

```sh
pip install -e ".[dev]"
pytest # 916 tests, ~20s
pytest # 1301 tests, ~20s
pytest --fuzz # same suite, 3000 examples per property (~3 min)
ruff check src tests
pytest --cov=offloader --cov-report=term-missing
```

916 tests at 89% line coverage. They cover formatting against the reference's
1301 tests at 88% line coverage. They cover formatting against the reference's
exact strings, checksum vectors and streaming equivalence, copy/verify
behaviour including simulated destination corruption, pause/resume/cancel
concurrency, retry discrimination, BRAW container parsing, ffprobe parsing,
Expand Down
10 changes: 5 additions & 5 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ example. BRAW metadata comes out of the container because ffprobe cannot read
the format at all, and has been run over 510 real clips from two camera bodies.

`offloader verify` re-checks the ASC MHL directory content and structure hashes,
not only the file hashes, so a rename or a moved file, which every file hash
agrees is fine, is reported as the structure-hash mismatch it is. See
not only the file hashes, so a rename or a moved file is reported as a missing
listed file and changed directories. See
[`docs/ascmhl.md`](docs/ascmhl.md#directory-hashes).

`--paranoid` reads every source file a second time and compares, which is the
Expand Down Expand Up @@ -69,7 +69,7 @@ than under another search root.

Verifying directory hashes made a rename visible; it did not make it
*explicable*. A renamed directory reports as one `MISSING` line and one
`RENAMED` parent, with nothing saying the first became the second. The format
`CHANGED` parent, with nothing saying the first became the second. The format
has `previousPath` for exactly this and it is not written.

*Where:* `ascmhl.py`, and `verify.py` to read it back.
Expand Down Expand Up @@ -136,8 +136,8 @@ would close it.
junctions. robocopy does these well and they do not apply to camera media.
- **Replacing the copy loop with robocopy.** Measured and rejected; see
[`docs/performance.md`](docs/performance.md). It copies faster and emits no
checksums, so the verified workflow it implies makes two extra passes over the
data.
checksums, so the verified workflow it implies makes one extra pass over the
source.
- **Cryptographic tamper evidence by default.** xxHash is chosen for accidental
corruption, which is the actual threat. `--hash sha256` is there for anyone
who needs the other thing.
Expand Down
24 changes: 18 additions & 6 deletions docs/data-safety.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ Unlisted files are a diagnostic, not a failure. What makes a missing clip fail i
that the manifest lists it; see "A manifest lists what did not arrive" below.

Where the manifest is an ASC MHL history, the directory hashes are recomputed
too, and they catch the one class of change no checksum can. Rename a clip and
every file still hashes exactly as recorded, the bytes did not move. The
structure hash folds each name in with its hash, so it does not agree:
too. Rename a clip and its bytes have not changed, but the path the manifest
lists is gone: the file is reported missing, every directory above it as
changed, and the new name as not in the manifest:

```
3 checked: 1 missing, 2 ok; 2 of 2 directory hashes differ
Expand Down Expand Up @@ -434,7 +434,9 @@ Still not covered: the directory hashes an *earlier* generation recorded are
not rechecked, so a rename of a file only an earlier generation lists is
caught as a missing file, not as a structure change. A path is matched by its
text, so a generation that renamed a file is not linked to the old name.
Generations are ordered by their sequence number, not by date.
Generations are ordered by their sequence number, not by date. And the
generations are not compared with the chain file: see "What is still not
protected".

### A manifest is never overwritten

Expand Down Expand Up @@ -513,6 +515,14 @@ safe direction.
Stated plainly, because a list of guarantees is only useful if its edges are
known.

- **ASC MHL generations are not checked against the chain file.** `verify`
re-hashes files and recomputes directory hashes, but does not compare each
generation's C4 ID with `ascmhl_chain.xml`. A generation that was replaced
or has gone missing is reported when the next one is written (a job
warning), never by `verify`.
- **Job warnings are not in the PDF, HTML or CSV reports.** The terminal
summary and the app show them when the job ends; the paperwork does not, so
a warning nobody read at the time is not on record afterwards.
- **Controller and drive caches.** As above: `full` verification proves the
operating system is not lying. It cannot prove the drive is not.
- **Source read errors that return garbage instead of raising**, unless
Expand Down Expand Up @@ -665,10 +675,12 @@ The tool cannot enforce this, but it is what the tool is built to support:
Do not erase the card until step 3 has passed on more than one copy.

A script can key off `offload`'s exit status: `0` Verified (or Copied under
`--verify none`) with every report written, `1` a file or source folder failed,
`--verify none`, with every file copied) and every report written, `1` a file
or source folder failed,
`2` could not run, `3` destination or control file refused, `4` nothing failed
but not everything was verified (unresolved timeline references, an empty
source, an all-skipped `--skip-existing` rerun), `5` the copies verified but a
source, a `--skip-existing` rerun that skipped any file), `5` the copies
verified but a
report or manifest could not be written, `130` cancelled (Ctrl+C or a
control-file cancel). The full table is in the README.

Expand Down
4 changes: 2 additions & 2 deletions docs/timeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ ignore the code.

A job cancelled with `offloader control PATH --cancel` exits 130, the same as
Ctrl+C, and its summary says how many files were not attempted. A failed file
still exits 1. Exit 4 is the code for any incomplete job (an empty source or an
all-skipped rerun as well); the full table is in the README.
still exits 1. Exit 4 is the code for any incomplete job (an empty source, or
a rerun that skipped any file, as well); the full table is in the README.

## Why `ambiguous` refuses instead of choosing

Expand Down
5 changes: 3 additions & 2 deletions src/offloader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
EXIT_ERROR = 2 # usage, environment, unreadable manifest
EXIT_REFUSED = 3 # unsafe destination or control file, nothing copied
EXIT_INCOMPLETE = 4 # unresolved timeline references, empty source,
# or an all-skipped rerun: nothing failed, but
# not everything asked for was verified
# or a rerun that skipped any file: nothing
# failed, but not everything asked for was
# verified
EXIT_REPORTS_FAILED = 5 # copies good, but a report or manifest failed
EXIT_CANCELLED = 130 # Ctrl+C or a control-file cancel
#: What `resolve` and a timeline `offload` return while any reference is
Expand Down
Loading