File Metadata and File Content

Metadata can describe an entry's name, permissions, size, or timestamps. Several of those values can change without an edit to the logical document.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a rename
  2. Choose what to compare
  3. Choose whether the evidence is content or file state
  4. Test the property the consumer uses

Trace a rename

Changing draft.txt to final.txt can leave its bytes untouched while changing how callers locate it. An open handle and a pathname can also continue to refer to different views after replacement. Atomic replacement shows one reason the distinction matters.

Choose what to compare

Two exports with equal byte content may have different modification times. Compare bytes or an appropriate digest when content equality is required. Record round trips define other meaningful notions of equality.[1]

Choose whether the evidence is content or file state

An application can update a report's modification time while leaving the bytes unchanged. A timestamp-based freshness test can see a change, while a content digest stays the same. On some filesystems a rapid rewrite may also share the same observed timestamp due to precision. See cache invalidation for files.

Before: file bytes AB, modified time T1
Metadata-only update: bytes AB, modified time T2
Byte digest unchanged
Timestamp key changes

Test the property the consumer uses

Backup and build tools can treat several metadata fields as part of identity. A plain byte comparison cannot verify permissions or timestamp preservation. Specify which fields matter and include a change to content without a change in filename.

References

  1. Python Software Foundation, io: Core Tools for Working with Streams ↩