immich-go icon indicating copy to clipboard operation
immich-go copied to clipboard

Edited files with same base names but different extension associated to the wrong sidecar file

Open chriseow opened this issue 7 months ago • 1 comments

I have the following files in Google photos

IMG_0102.HEIC
IMG_0102.HEIC.supplemental-metadata.json
IMG_0102.PNG
IMG_0102.PNG.supplemental-metadata.json
IMG_0102-edited.PNG

IMG_0102.HEIC and IMG_0102.PNG are 2 different images taking several years apart.

When uploading the takeouts, "IMG_0102-edited.PNG" is associated with "IMG_0102.HEIC.supplemental-metadata.json" instead of "IMG_0102.PNG.supplemental-metadata.json". So it was also added to the same album as "IMG_0102.HEIC", which is incorrect. See the following log entries: 2025-07-13 17:29:21 INF associated metadata file file=takeout-20250712T134852Z-1-002:Takeout/Google Photos/Archive/IMG_0102-edited.PNG json=IMG_0102.HEIC.supplemental-metadata.json matcher=matchEditedName

I examined the code for "matchEditedName" and realised it did not do a match for the file extension. Perhaps some additional code is needed to match the extension for the sidecar file as well?

I did some testing and got it to work by modifying the code as follows:

	ext := path.Ext(base) // original code

        // add this additional check for different extensions
	fileExt := path.Ext(fileName)
	if ext != "" && !strings.EqualFold(fileExt, ext) {
		return false // different extension
	}

        // original code
	if ext != "" && sm.IsMedia(ext) {
		base = strings.TrimSuffix(base, ext)
		fileName = strings.TrimSuffix(fileName, path.Ext(fileName))
	}

chriseow avatar Jul 15 '25 15:07 chriseow

I have a very similar issue. I did a very big import from google photos and ended up with lots of photos without a date. Looking at them it looks like most of them, if not all, are "-edited" files

droopanu avatar Sep 26 '25 23:09 droopanu