Skip to content

Commit 73a7dd9

Browse files
committed
fix Add an CLI option to pause backgroud jobs, true by default #909
add PauseImmichBackgroundJobs field and update flag handling in client
1 parent 3790efd commit 73a7dd9

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

app/client.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,21 @@ type Client struct {
2323
APIKey string // API Key
2424
AdminAPIKey string // API Key for admin
2525

26-
APITrace bool // Enable API call traces
27-
SkipSSL bool // Skip SSL Verification
28-
ClientTimeout time.Duration // Set the client request timeout
29-
DeviceUUID string // Set a device UUID
30-
DryRun bool // Protect the server from changes
31-
TimeZone string // Override default TZ
32-
TZ *time.Location // Time zone to use
33-
APITraceWriter io.WriteCloser // API tracer
34-
APITraceWriterName string // API trace log name
35-
Immich immich.ImmichInterface // Immich client
36-
AdminImmich immich.ImmichInterface // Immich client for admin
37-
ClientLog *slog.Logger // Logger
38-
OnServerErrors cliflags.OnServerErrorsFlag // Behavior on server errors
39-
User immich.User // User info corresponding to the API key
26+
APITrace bool // Enable API call traces
27+
SkipSSL bool // Skip SSL Verification
28+
ClientTimeout time.Duration // Set the client request timeout
29+
DeviceUUID string // Set a device UUID
30+
DryRun bool // Protect the server from changes
31+
TimeZone string // Override default TZ
32+
TZ *time.Location // Time zone to use
33+
APITraceWriter io.WriteCloser // API tracer
34+
APITraceWriterName string // API trace log name
35+
Immich immich.ImmichInterface // Immich client
36+
AdminImmich immich.ImmichInterface // Immich client for admin
37+
ClientLog *slog.Logger // Logger
38+
OnServerErrors cliflags.OnServerErrorsFlag // Behavior on server errors
39+
User immich.User // User info corresponding to the API key
40+
PauseImmichBackgroundJobs bool // Pause Immich background jobs
4041
}
4142

4243
// add server flags to the command cmd
@@ -46,9 +47,10 @@ func AddClientFlags(ctx context.Context, cmd *cobra.Command, app *Application, d
4647

4748
cmd.PersistentFlags().StringVarP(&client.Server, "server", "s", client.Server, "Immich server address (example http://your-ip:2283 or https://your-domain)")
4849
cmd.PersistentFlags().StringVarP(&client.APIKey, "api-key", "k", "", "API Key")
49-
cmd.PersistentFlags().StringVarP(&client.AdminAPIKey, "admin-api-key", "a", "", "Admin's API Key for managing server's jobs")
50-
50+
cmd.PersistentFlags().StringVar(&client.AdminAPIKey, "admin-api-key", "", "Admin's API Key for managing server's jobs")
5151
cmd.PersistentFlags().BoolVar(&client.APITrace, "api-trace", false, "Enable trace of api calls")
52+
53+
cmd.PersistentFlags().BoolVar(&client.PauseImmichBackgroundJobs, "pause-immich-jobs", true, "Pause Immich background jobs during upload operations")
5254
cmd.PersistentFlags().BoolVar(&client.SkipSSL, "skip-verify-ssl", false, "Skip SSL verification")
5355
cmd.PersistentFlags().DurationVar(&client.ClientTimeout, "client-timeout", 20*time.Minute, "Set server calls timeout")
5456
cmd.PersistentFlags().StringVar(&client.DeviceUUID, "device-uuid", client.DeviceUUID, "Set a device UUID")
@@ -114,6 +116,7 @@ func OpenClient(ctx context.Context, cmd *cobra.Command, app *Application) error
114116
return err
115117
}
116118
client.Immich.EnableAppTrace(client.APITraceWriter)
119+
client.AdminImmich.EnableAppTrace(client.APITraceWriter)
117120
}
118121
app.log.Message("Check the API-TRACE file: %s", client.APITraceWriterName)
119122
}
@@ -197,6 +200,7 @@ func (client *Client) Open(ctx context.Context) error {
197200
return err
198201
}
199202
client.Immich.EnableAppTrace(client.APITraceWriter)
203+
client.AdminImmich.EnableAppTrace(client.APITraceWriter)
200204
}
201205
}
202206

0 commit comments

Comments
 (0)