fix: sidecar inconsistency

This commit is contained in:
Jonathan Jogenfors
2026-09-29 23:27:52 +02:00
parent a29153e90e
commit 6bb95f3e22
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;
}