Principle:0xsline OpenChatCut Content Hash Deduplication
| Knowledge Sources | |
|---|---|
| Domains | Deduplication, Hashing, Media_Import |
| Last Updated | 2026-10-22 14:00 GMT |
Overview
Deduplication principle that computes a SHA-256 content hash of a media file to enable identity-based duplicate detection, with a size threshold to skip hashing for very large files where the I/O cost exceeds the dedup benefit.
Description
Content-Hash Deduplication uses the SHA-256 cryptographic hash of a file's contents as a unique identifier. Two files with the same content hash are considered identical, regardless of filename or path.
Key design decisions:
- SHA-256: A 64-character lowercase hex digest serves as the canonical hash form.
- Streaming hash: The file is read in a streaming fashion to avoid loading it entirely into memory.
- Size threshold: Files above 1.5 GB (`LARGE_HASH_SKIP_BYTES`) skip the hash computation — the second pass over multi-GiB masters costs more than content-addressed dedup can save, and the import pipeline (hash + normalize + ASR) already saturates disk I/O.
- Canonical form: `normalizeSha256Hash` validates and lowercases the hash; returns `undefined` for invalid input.
- Empty hash: Large files get an empty string hash (not `undefined`), distinguishing "skipped" from "invalid."
Usage
Use this principle when:
- Detecting duplicate media files by content identity.
- Building a content-addressed media store.
- Deciding whether to skip re-importing an identical file.
Theoretical Basis
Content-addressed storage uses the hash of the content as the identity:
# Abstract algorithm (NOT real implementation)
def content_hash(path, size):
if size > LARGE_THRESHOLD:
return "" # Skip — I/O cost exceeds dedup benefit
raw = sha256_streaming(path)
return normalize(raw) # lowercase 64-char hex
def is_duplicate(hash_a, hash_b):
return hash_a and hash_b and hash_a == hash_b
Related Pages
Implemented By
- Implementation:0xsline_OpenChatCut_Sha256File
- Implementation:0xsline_OpenChatCut_NormalizeSha256Hash
- Implementation:0xsline_OpenChatCut_ImportLocalMedia