Skip to content

fix(fromimmich): populate NameInfo so archive writes original filenames - #1429

Open
ryjogo wants to merge 1 commit into
simulot:mainfrom
ryjogo:fix/from-immich-filename
Open

ryjogo wants to merge 1 commit into
simulot:mainfrom
ryjogo:fix/from-immich-filename

Conversation

@ryjogo

@ryjogo ryjogo commented Aug 19, 2026

Copy link
Copy Markdown

Summary

archive from-immich writes every media file as ~1, ~2, ~3, … with no extension. This makes the resulting archive unbrowsable (no extension → not associated with any viewer) and non-re-importable (upload from-folder reports every file as discovered unknown file … reason=useless file).

The image data itself is intact — renaming a ~N file to its real name (present in the sibling .JSON) opens correctly.

Root cause

writeFolder.WriteAsset (adapters/folder/writeFolder.go) uses a.Base (from the embedded NameInfo) to name the output file. When Base is empty, its collision-avoidance loop treats the destination directory itself as a name collision and falls through to the ~N placeholder pattern.

Every other source adapter populates NameInfo via the InfoCollector:

  • adapters/folder/run.go:551 — a.SetNameInfo(ifc.infoCollector.GetInfo(n))
  • adapters/googlePhotos/googlephotos.go:509 — a.SetNameInfo(toc.infoCollector.GetInfo(a.OriginalFileName))
  • app/stack/stack.go:97 — asset.SetNameInfo(o.InfoCollector.GetInfo(asset.OriginalFileName))

fromimmich/command.go was setting Asset.OriginalFileName but never NameInfo. FromImmichCmd already initialises fic.ic (an InfoCollector), so the fix reuses it in the same pattern.

Fix

One line in adapters/fromimmich/command.go, immediately after asset := a.AsAsset():

asset.SetNameInfo(fic.ic.GetInfo(a.OriginalFileName))

Verification

Rebuilt from this branch and re-ran archive from-immich against Immich v3.1.0. Output now matches the format described in docs/commands/archive.md:

originals/2021/2021-09/IMG_5809.HEIC
originals/2021/2021-09/IMG_5809.HEIC.JSON
originals/2021/2021-08/IMG_5772.JPG
originals/2021/2021-08/IMG_5772.JPG.JSON

Fixes #1412

The archive from-immich command was writing every media file as ~1, ~2, ...
with no extension, because the from-immich adapter set Asset.OriginalFileName
but never populated the embedded NameInfo (Base/Ext/Radical).

writeFolder.WriteAsset uses a.Base to name the output file; when Base is
empty, its disambiguation loop treats the destination directory itself as a
name collision and falls through to the placeholder pattern.

Every other source adapter (folder, googlePhotos, stack) already calls
SetNameInfo via the InfoCollector. This aligns fromimmich with the same
pattern using the already-initialised fic.ic collector.

Fixes simulot#1412
@ryjogo
ryjogo requested a review from simulot as a code owner August 19, 2026 17:54

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant