aboutsummaryrefslogtreecommitdiff
path: root/duplicate_finder/types.py
diff options
context:
space:
mode:
Diffstat (limited to 'duplicate_finder/types.py')
-rw-r--r--duplicate_finder/types.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/duplicate_finder/types.py b/duplicate_finder/types.py
new file mode 100644
index 0000000..f2438d8
--- /dev/null
+++ b/duplicate_finder/types.py
@@ -0,0 +1,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]