浏览代码

Sort dedupe size descending (#1564)

Abhinav Kumar 1 年之前
父节点
当前提交
77024ca15c
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      apps/photos/src/services/deduplicationService.ts

+ 6 - 2
apps/photos/src/services/deduplicationService.ts

@@ -26,7 +26,11 @@ export async function getDuplicates(
     collectionNameMap: Map<number, string>
 ) {
     try {
-        const dupes = await fetchDuplicateFileIDs();
+        const ascDupes = await fetchDuplicateFileIDs();
+
+        const descSortedDupes = ascDupes.sort((firstDupe, secondDupe) => {
+            return secondDupe.size - firstDupe.size;
+        });
 
         const fileMap = new Map<number, EnteFile>();
         for (const file of files) {
@@ -35,7 +39,7 @@ export async function getDuplicates(
 
         let result: Duplicate[] = [];
 
-        for (const dupe of dupes) {
+        for (const dupe of descSortedDupes) {
             let duplicateFiles: EnteFile[] = [];
             for (const fileID of dupe.fileIDs) {
                 if (fileMap.has(fileID)) {