diff --git a/app/upload/run.go b/app/upload/run.go index 4544a7937..5ffbe746e 100644 --- a/app/upload/run.go +++ b/app/upload/run.go @@ -422,18 +422,22 @@ func (uc *UpCmd) handleAsset(ctx context.Context, a *assets.Asset) error { return nil } -// uploadAsset uploads the asset to the server. -// set the server's asset ID to the asset. -// return the duplicate condition and error. -func (uc *UpCmd) uploadAsset(ctx context.Context, a *assets.Asset) (string, error) { - defer uc.app.Log().Debug("upload asset", "file", a) - +// addCommandLineTags adds the --tag values and, if --session-tag is set, the session tag to the +// asset, so that manageAssetTags applies them on the server. +func (uc *UpCmd) addCommandLineTags(a *assets.Asset) { if uc.SessionTag { a.AddTag(uc.session) } for _, tag := range uc.Tags { a.AddTag(tag) } +} + +// uploadAsset uploads the asset to the server. +// set the server's asset ID to the asset. +// return the duplicate condition and error. +func (uc *UpCmd) uploadAsset(ctx context.Context, a *assets.Asset) (string, error) { + defer uc.app.Log().Debug("upload asset", "file", a) ar, err := uc.client.Immich.AssetUpload(ctx, a) if err != nil { @@ -570,6 +574,7 @@ func (uc *UpCmd) processUploadedAsset(ctx context.Context, a *assets.Asset, serv // TODO: current version of Immich doesn't allow to add same tag to an asset already tagged. // there is no mean to go the list of tagged assets for a given tag. uc.manageAssetAlbums(ctx, a.File, a.ID, a.Albums) + uc.addCommandLineTags(a) uc.manageAssetTags(ctx, a) } } diff --git a/internal/e2e/client/replace_test.go b/internal/e2e/client/replace_test.go index 72a9fa5d1..554cf9ef3 100644 --- a/internal/e2e/client/replace_test.go +++ b/internal/e2e/client/replace_test.go @@ -125,6 +125,7 @@ func Test_Replace(t *testing.T) { "--no-ui", "--api-trace", "--log-level=debug", + "--tag=replaced", // must also reach the replacement uploads "DATA/replace/high_quality", }) err = c.ExecuteContext(ctx) @@ -140,7 +141,7 @@ func Test_Replace(t *testing.T) { e2eutils.CheckResults(t, map[fileevent.Code]int64{ fileevent.ProcessedUploadSuccess: 0, fileevent.ProcessedAlbumAdded: 0, - fileevent.ProcessedTagged: 0, + fileevent.ProcessedTagged: 5, fileevent.ProcessedUploadUpgraded: 5, }, false, a.FileProcessor())