1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Small shared helpers used across the in-lane store backends.
//!
//! Kept crate-private so the three [`Store`](snapdir_core::store::Store)
//! implementations (`file://`, `s3://`, `gs://`) share one definition of the
//! fetch-side "already present and verified?" decision rather than each
//! reimplementing it.
use Path;
use Hasher;
use StoreError;
/// Hashes a file's full byte content with `hasher`, returning its hex digest.
///
/// Reused by every backend's `fetch_files` to recompute a destination file's
/// content address (BLAKE3) for the skip-if-present-and-verified check.
pub
/// Returns `true` when `target` already exists as a regular file whose
/// locally-recomputed content hash equals `expected`.
///
/// This is the fetch-side skip gate: a present, checksum-matching destination
/// file never needs to be re-copied or re-downloaded (and a mismatching one is
/// left for the caller to repair by overwriting). The check is content-gated,
/// not mere existence — a corrupt local file returns `false` so it gets
/// re-fetched, and any non-file (directory, symlink target, …) also returns
/// `false`.
///
/// A read error while hashing an existing file is treated as "not a clean
/// match" (`false`) rather than propagated, so a transiently unreadable
/// destination falls through to a normal fetch instead of aborting the run.
pub