Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:0xsline OpenChatCut Content Hash Deduplication

From Leeroopedia
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

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment