π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Impl
Manav Rathi1d02732719e8
diff --git a/web/packages/media/file.ts b/web/packages/media/file.tsindex ff6231fde1..e44846ab54 100644--- a/web/packages/media/file.ts+++ b/web/packages/media/file.ts@@ -22,6 +22,9 @@ export interface S3FileAttributes {}export interface FileInfo {+ /**+ * The size of the file, in bytes.+ */fileSize: number;thumbSize: number;}diff --git a/web/packages/new/photos/services/dedup.ts b/web/packages/new/photos/services/dedup.tsindex 163fb71520..49f5132246 100644--- a/web/packages/new/photos/services/dedup.ts+++ b/web/packages/new/photos/services/dedup.ts@@ -1,5 +1,5 @@import type { EnteFile } from "@/media/file";-import { wait } from "@/utils/promise";+import { getLocalFiles, uniqueFilesByID } from "./files";/*** A group of duplicates as shown in the UI.@@ -65,14 +65,39 @@ export interface DuplicateGroup {* 4. Delete the remaining files.*/export const deduceDuplicates = async () => {- await wait(1000);- return [- {- items: [],- itemSize: 0,- prunableCount: 0,- prunableSize: 0,+ const collectionFiles = await getLocalFiles();+ const files = uniqueFilesByID(collectionFiles);++ const filesByHash = new Map<string, EnteFile[]>();+ for (const file of files) {+ let hash = file.metadata.hash;+ if (!hash && file.metadata.imageHash && file.metadata.videoHash)+ hash = `${file.metadata.imageHash}_${file.metadata.hash}`;+ if (!hash) {+ // Some very old files uploaded by ancient versions of Ente might+ // not have hashes. Ignore these.+ continue;+ }++ filesByHash.set(hash, [...(filesByHash.get(hash) ?? []), file]);+ }++ const duplicateGroups: DuplicateGroup[] = [];++ for (const potentialDuplicates of filesByHash.values()) {+ if (potentialDuplicates.length < 2) continue;+ const size = potentialDuplicates[0]?.info?.fileSize;+ if (!size) continue;+ const duplicates = potentialDuplicates.filter(+ (file) => file.info?.fileSize == size,+ );+ if (duplicates.length < 2) continue;+ duplicateGroups.push({+ items: duplicates.map((file) => ({ file, collectionName: "TODO" })),+ itemSize: size,+ prunableCount: duplicates.length - 1,+ prunableSize: size * (duplicates.length - 1),isSelected: true,- },- ];+ });+ }};