From f5839105a77127d86398148a2dea471caba3f4c8 Mon Sep 17 00:00:00 2001 From: "immich-push-o-matic[bot]" <179150890+immich-push-o-matic[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 14:44:08 +0000 Subject: [PATCH] fix(cli): sidecar precedence (#32021) fix(cli): sidecar precedence (#31929) (cherry picked from commit 1ba6a5f33853624d1a11773fbdb00a6136ccc6dd) Co-authored-by: Jonathan Jogenfors --- packages/cli/src/commands/asset.spec.ts | 3 +-- packages/cli/src/commands/asset.ts | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/asset.spec.ts b/packages/cli/src/commands/asset.spec.ts index 7e582039b..a105d09d4 100644 --- a/packages/cli/src/commands/asset.spec.ts +++ b/packages/cli/src/commands/asset.spec.ts @@ -385,8 +385,7 @@ describe('findSidecar', () => { fs.writeFileSync(sidecarPath2, 'xmp data 2'); const result = findSidecar(testFilePath); - // Should return the first one found (photo.xmp) based on the order in the code - expect(result).toBe(sidecarPath1); + expect(result).toBe(sidecarPath2); }); it('should return undefined when no sidecar file exists', () => { diff --git a/packages/cli/src/commands/asset.ts b/packages/cli/src/commands/asset.ts index 6aab96dc3..ac6f5eb99 100644 --- a/packages/cli/src/commands/asset.ts +++ b/packages/cli/src/commands/asset.ts @@ -445,8 +445,8 @@ export const findSidecar = (filepath: string): string | undefined => { const assetPath = path.parse(filepath); const noExtension = path.join(assetPath.dir, assetPath.name); - // XMP sidecars can come in two filename formats. For a photo named photo.ext, the filenames are photo.ext.xmp and photo.xmp - for (const sidecarPath of [`${noExtension}.xmp`, `${filepath}.xmp`]) { + // Prefer photo.ext.xmp over photo.xmp, matching the server's sidecar precedence. + for (const sidecarPath of [`${filepath}.xmp`, `${noExtension}.xmp`]) { if (existsSync(sidecarPath)) { return sidecarPath; }