Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new AutoArchive option #450

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cmd/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type UpCmd struct {
StackJpgRaws bool // Stack jpg/raw (Default: TRUE)
StackBurst bool // Stack burst (Default: TRUE)
DiscardArchived bool // Don't import archived assets (Default: FALSE)
AutoArchive bool // Automatically archive photos that are also archived in google photos (Default: FALSE)
WhenNoDate string // When the date can't be determined use the FILE's date or NOW (default: FILE)
ForceUploadWhenNoJSON bool // Some takeout don't supplies all JSON. When true, files are uploaded without any additional metadata
BannedFiles namematcher.List // List of banned file name patterns
Expand Down Expand Up @@ -161,6 +162,10 @@ func newCommand(ctx context.Context, common *cmd.SharedFlags, args []string, fsO
"discard-archived",
" google-photos only: Do not import archived photos (default FALSE)", myflag.BoolFlagFn(&app.DiscardArchived, false))

cmd.BoolFunc(
"auto-archive",
" google-photos only: Automatically archive photos that are also archived in google photos (default FALSE)", myflag.BoolFlagFn(&app.AutoArchive, false))

cmd.BoolFunc(
"create-stacks",
"Stack jpg/raw or bursts (default FALSE)", myflag.BoolFlagFn(&app.CreateStacks, false))
Expand Down Expand Up @@ -473,6 +478,10 @@ func (app *UpCmd) handleAsset(ctx context.Context, a *browser.LocalAssetFile) er
return nil
}
app.manageAssetAlbum(ctx, ID, a, advice)
if app.AutoArchive && a.Archived {
a.Archived = true
app.Immich.UpdateAsset(ctx, ID, a)
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify this code.

The AssetUpload method of the immich client must be updated to handle the Archived flag:

immich-go/immich/asset.go

Lines 125 to 127 in d58d266

// m.WriteField("isArchived", myBool(la.Archived).String()) // Not supported by the api
h := textproto.MIMEHeader{}

Doing so, you'll save one call

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add commit that mention the fix of the #448


case SmallerOnServer: // Upload, manage albums and delete the server's asset
app.Jnl.Record(ctx, fileevent.UploadUpgraded, a, a.FileName, "reason", advice.Message)
Expand Down