fix(postprocessing): restart postprocessing properly
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
@@ -83,11 +83,15 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "restart",
|
||||
Usage: "send restart event for all listed sessions",
|
||||
Usage: "send restart event for all listed sessions. Only one of resume/restart/clean can be set.",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "resume",
|
||||
Usage: "send resume event for all listed sessions. Only one of resume/restart/clean can be set.",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "clean",
|
||||
Usage: "remove uploads",
|
||||
Usage: "remove uploads for all listed sessions. Only one of resume/restart/clean can be set.",
|
||||
},
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
@@ -176,8 +180,9 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if c.Bool("restart") {
|
||||
if err := events.Publish(context.Background(), stream, events.ResumePostprocessing{
|
||||
switch {
|
||||
case c.Bool("restart"):
|
||||
if err := events.Publish(context.Background(), stream, events.RestartPostprocessing{
|
||||
UploadID: u.ID(),
|
||||
Timestamp: utils.TSNow(),
|
||||
}); err != nil {
|
||||
@@ -185,9 +190,18 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
// if publishing fails there is no need to try publishing other events - they will fail too.
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
if c.Bool("clean") {
|
||||
case c.Bool("resume"):
|
||||
if err := events.Publish(context.Background(), stream, events.ResumePostprocessing{
|
||||
UploadID: u.ID(),
|
||||
Timestamp: utils.TSNow(),
|
||||
}); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to send resume event for upload session '%s'\n", u.ID())
|
||||
// if publishing fails there is no need to try publishing other events - they will fail too.
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
case c.Bool("clean"):
|
||||
if err := u.Purge(c.Context); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to clean upload session '%s'\n", u.ID())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user