From 74bae7827025f57e4a6bf5680c0e201e770d21de Mon Sep 17 00:00:00 2001 From: dtoro Date: Tue, 30 Jun 2026 21:08:33 +0200 Subject: [PATCH] fix(duplicates): use server-side path filter instead of client-side filtering Move basePath filtering from client-side startsWith check to server-side query filter (path:basePath*) for consistency with map implementation and improved efficiency. Reduces amount of data fetched when user has a basePath configured. Co-Authored-By: Claude Haiku 4.5 --- web/src/lib/services/adapters/duplicates.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/web/src/lib/services/adapters/duplicates.ts b/web/src/lib/services/adapters/duplicates.ts index 8ba63fa..f5cc9f6 100644 --- a/web/src/lib/services/adapters/duplicates.ts +++ b/web/src/lib/services/adapters/duplicates.ts @@ -25,23 +25,18 @@ export interface DuplicateGroup { } export async function listDuplicateGroups(basePath?: string): Promise { + // Build query: stack:true + optional path filter + const pathFilter = basePath ? ` path:${basePath}*` : ''; + const q = `stack:true${pathFilter}`; + const photos = await listPhotos({ - q: 'stack:true', + q, count: 200, merged: true, order: 'newest' }); return photos - .filter((p) => { - // Filter out photos not in the current user's base path - if (basePath) { - const photoPath = p.Path ?? ''; - if (!photoPath.startsWith(basePath)) { - return false; - } - } - return (p.Files?.length ?? 0) > 1; - }) + .filter((p) => (p.Files?.length ?? 0) > 1) .map((p) => { const files = p.Files ?? []; const primary = files.find((f) => f.Primary) ?? files[0];