fix(cli): sidecar precedence (#32021)

fix(cli): sidecar precedence (#31929)

(cherry picked from commit 1ba6a5f33853624d1a11773fbdb00a6136ccc6dd)

Co-authored-by: Jonathan Jogenfors <jonathan@jogenfors.se>
This commit is contained in:
immich-push-o-matic[bot]
2026-10-02 14:44:08 +00:00
committed by GitHub
co-authored by Jonathan Jogenfors
parent 2bb3d0807f
commit f5839105a7
2 changed files with 3 additions and 4 deletions
+1 -2
View File
@@ -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', () => {
+2 -2
View File
@@ -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;
}