metadata

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DirHeader = "tiedir-v2\n---\n"

DirHeader prefixes every tie directory blob. A directory's hash changes whenever its contents change, which gives git-like versioning for free.

View Source
const MagicNumber = 261

MagicNumber is how many leading bytes of a file are needed to sniff its media type.

Variables

This section is empty.

Functions

func DecodeHead

func DecodeHead(s string) ([]byte, error)

func EncodeHead

func EncodeHead(head []byte) string

func HashReader

func HashReader(r io.Reader) (string, error)

HashReader returns the tie content address of everything read from r.

func HexHashBlobPolicy

func HexHashBlobPolicy() *tiedb.BlobPolicy

HexHashBlobPolicy returns the tiedb blob policy that stores content-address hashes as raw 32-byte entries instead of chunking their 64-char hex form into the trie. A hash is the worst case for the chunk trie (no shared prefixes, 3 entries per hash); this collapses it to one. Encode matches only well-formed hex hashes; Decode re-hex-encodes the raw bytes back to the stored string.

func IsDirHead

func IsDirHead(head []byte) bool

IsDirHead reports whether head bytes belong to a tie directory blob (any tiedir version), used to classify an entry as a directory.

func IsHexHash

func IsHexHash(s string) bool

IsHexHash reports whether s is a well-formed content address: exactly 64 lowercase hex characters. Enforced on parse so an untrusted manifest cannot smuggle a traversal or SSRF payload through the hash column.

func MediaType

func MediaType(head []byte) string

MediaType classifies head bytes into a MIME type. It is recomputable from the head stored in each tiedir entry.

func NewHash

func NewHash() (hash.Hash, error)

NewHash returns a fresh keyed highwayhash. All content addresses in tie are computed with it, so upload hashing and download verification stay identical.

Types

type DirEntry

type DirEntry struct {
	Hash     string
	Filename string
	Size     int
	Head     []byte
}

DirEntry is one line of a tiedir blob. The head column stores the file's first bytes (rather than a derived media type) so classification stays recomputable as detectors improve.

func ParseDirLine

func ParseDirLine(line string) (DirEntry, bool)

ParseDirLine parses one tiedir-v2 line. It returns false for malformed lines. The filename must be a single path component: entries store a child's own name, never a path, so a crafted manifest cannot escape the checkout root via "..", an absolute path, or a nested separator.

func (DirEntry) Line

func (e DirEntry) Line() string

Line renders the entry as a tiedir-v2 line (trailing newline included). The head bytes are base64-encoded so tabs/newlines in the raw bytes cannot break column or line splitting; head is last so a malformed value cannot shift earlier columns.

type Media

type Media struct {
	Hash      string
	MediaType string
	Title     string
	Artist    string
	Album     string
	Year      int
	Track     int
	Duration  float64 // audio playing time in seconds, 0 when unknown
}

Media carries per-file media metadata extracted client-side at import time (audio tags via the vendored tie/tag fork of dhowden/tag). It feeds import-destination templates and per-file metadata triples; absent fields stay zero.

Directories

Path Synopsis
Package tag provides MP3 (ID3: v1, 2.2, 2.3 and 2.4), MP4, FLAC and OGG metadata detection, parsing and artwork extraction.
Package tag provides MP3 (ID3: v1, 2.2, 2.3 and 2.4), MP4, FLAC and OGG metadata detection, parsing and artwork extraction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL