blob: f2438d865ef3eb6ee1492efaa7268e1feebef208 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause
"""Types used throughout the duplicate-file finder."""
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
type FileIdentity = tuple[int, int]
type FileSize = int
type FileHash = str
type FileExtension = str
@dataclass(frozen=True, slots=True)
class FileInfo:
"""Store filesystem metadata collected while discovering a file.
:param path: Path through which the file was discovered.
:param size: File size in bytes.
:param identity: Filesystem identity as ``(device, inode)``.
"""
path: Path
size: FileSize
identity: FileIdentity
type FileSet = set[FileInfo]
type FilesByIdentity = defaultdict[FileIdentity, FileSet]
type CandidateGroupKey = FileSize | tuple[FileSize, FileExtension]
type FilesByCandidateGroup = dict[CandidateGroupKey, FilesByIdentity]
type FilesByHash = dict[FileHash, FileSet]
|