mirror of
https://github.com/kopia/kopia.git
synced 2026-01-02 19:47:51 -05:00
* fixed godot linter errors * reformatted source with gofumpt * disabled some linters * fixed nolintlint warnings * fixed gci warnings * lint: fixed 'nestif' warnings * lint: fixed 'exhaustive' warnings * lint: fixed 'gocritic' warnings * lint: fixed 'noctx' warnings * lint: fixed 'wsl' warnings * lint: fixed 'goerr113' warnings * lint: fixed 'gosec' warnings * lint: upgraded linter to 1.30.0 * lint: more 'exhaustive' warnings Co-authored-by: Nick <nick@kasten.io>
38 lines
884 B
Go
38 lines
884 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/kopia/kopia/internal/apiclient"
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
)
|
|
|
|
var serverStartUploadCommand = serverCommands.Command("upload", "Trigger upload for one or more sources")
|
|
|
|
func init() {
|
|
serverStartUploadCommand.Action(serverAction(runServerStartUpload))
|
|
}
|
|
|
|
func runServerStartUpload(ctx context.Context, cli *apiclient.KopiaAPIClient) error {
|
|
return triggerActionOnMatchingSources(ctx, cli, "sources/upload")
|
|
}
|
|
|
|
func triggerActionOnMatchingSources(ctx context.Context, cli *apiclient.KopiaAPIClient, path string) error {
|
|
var resp serverapi.MultipleSourceActionResponse
|
|
|
|
if err := cli.Post(ctx, path, &serverapi.Empty{}, &resp); err != nil {
|
|
return err
|
|
}
|
|
|
|
for src, resp := range resp.Sources {
|
|
if resp.Success {
|
|
fmt.Println("SUCCESS", src)
|
|
} else {
|
|
fmt.Println("FAILED", src)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|