Tracking
Central log of failed or unprofitable compressions.
-
remote_compression.tracking.REASONS = {'exception', 'ffmpeg_error', 'not_profitable', 'ori_exists', 'probe_failed', 'target_exists'}
transient issues (lost
connection, upload errors) are not recorded, so they are naturally retried.
- Type:
Recorded reasons. Deterministic failures only
-
class remote_compression.tracking.Tracker(path=None)[source]
JSON-backed store of files not worth re-trying.
An entry is only honored while the file’s size and mtime still match: a
replaced or edited file is retried. Writes are immediate and atomic
(temporary file + os.replace()), so a crash never loses the log.
- Parameters:
path (Path or str, optional) – Alternative file location (defaults to tracking_path()).
-
clear(file)[source]
Remove the entry for file (no-op if absent); called after a success.
-
discard_key(key)[source]
Remove one entry by canonical key, without saving.
- Returns:
Whether an entry was removed. The removal is remembered so a later
save() does not resurrect the key from the disk state.
- Return type:
bool
-
load()[source]
Load the file; a corrupt or missing file yields an empty store (with a warning).
-
prune()[source]
Drop entries whose file has disappeared or changed.
- Returns:
Number of entries removed.
- Return type:
int
-
record(file, reason, detail='')[source]
Add or replace an entry and save immediately.
- Parameters:
file (Path or str) – File to remember.
reason (str) – One of REASONS.
detail (str) – Free-form context (e.g. truncated ffmpeg stderr).
-
save()[source]
Merge with the on-disk state, then write atomically.
Several rcomp runs may share this file (parallel batches on different
disks): starting from the disk state keeps their entries alive, our own
removals stay removed, and our entries win on conflicting keys.
-
should_skip(file)[source]
- Parameters:
file (Path or str) – Candidate file.
- Returns:
The recorded reason if an entry exists and the file is unchanged
(same size and mtime), None otherwise.
- Return type:
str or None
-
remote_compression.tracking.tracking_key(file)[source]
- Parameters:
file (Path or str) – File location.
- Returns:
Canonical key: resolved absolute path, case-normalized (Windows paths
are case-insensitive).
- Return type:
str
-
remote_compression.tracking.tracking_path()[source]
- Returns:
Location of the tracking file.
- Return type:
Path