simulot / immich-go

An alternative to the immich-CLI command that doesn't depend on nodejs installation. It tries its best for importing google photos takeout archives.
GNU Affero General Public License v3.0
1.2k stars 36 forks source link

Replace OriginalFileName + Extension with path.Base() #217

Closed matthewkeller36 closed 1 month ago

matthewkeller36 commented 3 months ago

Packs the filename to include both name and extension. Removes issues with duplicate extensions being listed when a.OriginalFileName already contains the extension.

Example file: IMG_1011.JPG

Original: Name = IMG_1011.JPG.JPG New: Name = IMG_1011.JPG

This was causing issues with --ignore-extension only removing one extension when comparing names rather than both.

simulot commented 3 months ago

I remember some issues around this. We may have file names with dots liker '2023.04.23.original.jpg' and '2023.04.23.modified.jpg' which aren't real duplicates too.

matthewkeller36 commented 3 months ago

From my understanding, path.Base should still return the full filename with extension (2023.04.23.original.jpg), correct? Then, if we are using the -ignore-extension tag, we could remove the extension from the Name field using TrimSuffix. This would not cause issues with files containing multiple dots since only the extension suffix is trimmed, not the rest of the name.

simulot commented 3 months ago

Trimming the result of path.Ext() isn't safe: https://go.dev/play/p/QnxJjl8x3iu

Maybe only trim extension recognized by the server... several time to check cases like image.cr3.jpg

matthewkeller36 commented 3 months ago

I do not see the issue being shown in that example. It is outputting the full extension which the code should be doing correctly. The only case I can see using path.Base and then TrimSuffix would cause an issue would be for files whose name is only the extension (.jpg, .png, etc.) but this would be horrible naming convention to use already. https://go.dev/play/p/VJJBa8YRRqK

simulot commented 2 months ago

I'm working on the TUI for the duplicate command... image

The are plenty of changes for TUI I'll fix that