Function merge_into

Source
pub fn merge_into(
    catalog: &mut Catalog,
    records: Vec<FileAnalysis>,
    now: u64,
) -> Attachment
Expand description

Stores records in the catalog, attaching each to the file it describes.

Three outcomes make the order of analysis and scanning irrelevant:

  • the path is one the catalog holds — the usual case;
  • the path is unknown, but one file has the same size and whole-file MD5; older reports without a digest can use a unique name and size instead; the record is refiled under its current location;
  • nothing matches, and the record is kept as it is. The folder it names has most likely not been scanned yet.

Exact-path and legacy name-and-size matches also require the old size and modification date. A digest match proves the bytes agree, so a changed timestamp alone is harmless. Duplicate digests remain unresolved.