Skip to content

feat: implement --tag-via-sidecar when uploading#1131

Open
niieani wants to merge 1 commit intosimulot:developfrom
niieani:feat/tag-via-sidecar
Open

feat: implement --tag-via-sidecar when uploading#1131
niieani wants to merge 1 commit intosimulot:developfrom
niieani:feat/tag-via-sidecar

Conversation

@niieani
Copy link
Contributor

@niieani niieani commented Oct 13, 2025

fixes #990

Write tags into a temporary XMP sidecar before uploading, instead of using Immich tag APIs as a workaround for Immich's race condition in immich-app/immich#16747.
This means tags are attached as part of the initial POST asset upload, in the sidecarData multipart, instead of as subsequent calls to Immich's API.
If there's no sidecar, we create one (with just the tags), and if there is one, we losslessly modify its copy, by adding tags to it before sending it to Immich.

Changes

  • cleans up the generated files after upload
  • introduce XMP sidecar tag writer helpers and expand the reader so existing tags, ratings, and namespaces round-trip correctly when merging sidecars
  • document the new flag and cover the sidecar writer with unit tests and fixture updates
  • adds DEBUG logs for the new functionality
  • adds tests

@niieani niieani force-pushed the feat/tag-via-sidecar branch from 27d80b5 to c13981a Compare November 18, 2025 06:53
@niieani
Copy link
Contributor Author

niieani commented Nov 18, 2025

@simulot rebased on develop

@binarybumpkin
Copy link

binarybumpkin commented Jan 21, 2026

As per immich-app/immich#16747 (comment) I've tested this feature works, after the race condition issue in immich-app/immich#16747 was closed, but continues not to work for me with immich-go v0.21.0 and immich v2.4.1.

Thanks for developing this feature, looking forward to seeing immich fix the tagging issue via API and/or this feature being merged into immich-go!

Edit: One more commit to resolve immich-app/immich#16747 in immich-app/immich#25435 by the looks.

@BenCzaczkes
Copy link

I run my own tests based on the https://github.com/binarybumpkin method
Sadly, I found out that only one tag is discovered when using immich-go.exe upload from-folder --album-path-joiner="-" --date-from-name=FALSE --log-level="DEBUG" --session-tag=FALSE --api-trace=TRUE --server=http://localhost:2283 --tag-via-sidecar --on-errors=continue --folder-as-tags=FALSE --recursive=FALSE --api-key=xxx -l="./$(ln)" "$PWD"
relevant part of the log (word of warning, I'm no GO expert, so I could have done something wrong)
2026-01-23 15:24:50 INF discovered image file=1959-01:1.jpg
2026-01-23 15:24:50 INF discovered sidecar file=1959-01:1.jpg.JSON
2026-01-23 15:24:50 WRN discovered unknown file file=1959-01:Log20260123T1524488965.btm reason=useless file
2026-01-23 15:24:50 INF discovered sidecar file=1959-01:1.jpg.JSON
2026-01-23 15:24:50 INF Assets on the server: 0
2026-01-23 15:24:50 INF tagged file=1959-01:1.jpg tag=USA/California/San Francisco method=sidecar
2026-01-23 15:24:50 INF tag via sidecar applied file=1.jpg tags=USA/California/San Francisco
2026-01-23 15:24:50 DBG tag via sidecar wrote temporary sidecar file=1.jpg path=C:\Users\BenC\AppData\Local\Temp\immich-go-tag-sidecars-3212669342\1.jpg.xmp
2026-01-23 15:24:50 INF uploaded successfully file=1959-01:1.jpg
2026-01-23 15:24:50 INF metadata updated file=1959-01:1.jpg
2026-01-23 15:24:50 DBG upload asset file.OriginalFileName=1.jpg file.FileName=1959-01:1.jpg file.ID=61b8a3e0-7100-412e-868c-f1c147161da9 file.FileDate=2026-01-22 21:28:51 file.Description=9 month old me and my dad file.FileSize=1683398 file.CaptureDate=1959-01-28 10:00:00 file.Trashed=false file.Archived=false file.FromPartner=false file.Favorite=false file.Stars=0 file.Latitude=32.xxxxx file.Longitude=35.xxxxx
2026-01-23 15:24:50 INF added to album file=1959-01:1.jpg album=Dan 1959
2026-01-23 15:24:50 INF added to album file=1959-01:1.jpg album=Dan 2001
2026-01-23 15:24:50 INF created album album=Dan 1959 assets=1
2026-01-23 15:24:50 INF created album album=Dan 2001 assets=1
2026-01-23 15:24:50 INF Immich Job command sent resume=thumbnailGeneration
2026-01-23 15:24:50 INF Immich Job command sent resume=metadataExtraction
2026-01-23 15:24:51 INF Immich Job command sent resume=videoConversion
2026-01-23 15:24:51 INF Immich Job command sent resume=faceDetection
2026-01-23 15:24:51 INF Immich Job command sent resume=smartSearch

contents of 1.jpg.json
"software": "immich-go version:0.28.0, commit:8300f4f1ad617ab013e6f1180b4008019a014d2e, date:2025-09-22T09:00:04Z",
"fileName": "1.jpg",
"latitude": 31.793263,
"longitude": 35.216578,
"fileDate": "2026-01-14T12:16:30Z",
"dateTaken": "1959-01-28T10:00:00Z",
"description": "9 month old me and my dad",
"albums": [
{
"title": "Dan 1959",
"description": "this"
},
{
"title": "Dan 2001",
"description": "this Alfred"
}
],
"tags": [
{ "value": "USA/California/San Francisco" },
{ "value": "IL/Jerusalem" }
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants