exlab_wizard.sync.manifest#

Parser for rclone lsjson output into a run-relative remote manifest.

Sole owner of the lsjson wire shape. Consumers (the NAS sync client’s routine reconcile and cleanup remote-existence probe) depend only on the RemoteManifest value object, never on the raw JSON.

Functions

parse_lsjson(raw, *[, strip_prefix])

Parse rclone lsjson array text into a RemoteManifest.

Classes

RemoteEntry(size, mod_time, is_dir)

One file on the remote.

RemoteManifest(entries)

Run-relative view of a remote subtree.

class exlab_wizard.sync.manifest.RemoteEntry(size, mod_time, is_dir)[source]#

Bases: object

One file on the remote. mod_time is the RFC3339 string as emitted.

Parameters:
is_dir: bool#
mod_time: str#
size: int#
class exlab_wizard.sync.manifest.RemoteManifest(entries)[source]#

Bases: object

Run-relative view of a remote subtree. Keyed by POSIX rel-path.

Parameters:

entries (dict[str, RemoteEntry])

entries: dict[str, RemoteEntry]#
has(rel_path)[source]#

True iff rel_path is present on the remote (existence probe).

Parameters:

rel_path (str)

Return type:

bool

matches(rel_path, local_size, local_mtime, *, tolerance_s)[source]#

The single reconcile predicate: present AND size-equal AND modtime close.

local_mtime is the local file’s st_mtime (epoch seconds). A file is credited as synced only when the remote entry exists, its size equals local_size, and its modtime is within tolerance_s of local (rclone preserves modtime on copy; the window absorbs SFTP/SMB rounding).

Parameters:
Return type:

bool

size_matches(rel_path, local_size)[source]#

True iff rel_path is present and its remote size equals local.

Parameters:
  • rel_path (str)

  • local_size (int)

Return type:

bool

exlab_wizard.sync.manifest.parse_lsjson(raw, *, strip_prefix='')[source]#

Parse rclone lsjson array text into a RemoteManifest.

Directory entries are dropped. strip_prefix (e.g. <base_root>/<equipment_id>/<run>) is removed from each Path so keys are run-relative. Malformed / empty input yields an empty manifest (logged at debug) rather than raising — a listing we can’t parse must not crash the sync worker.

Parameters:
  • raw (str)

  • strip_prefix (str)

Return type:

RemoteManifest