Show restore progress details
This commit is contained in:
@@ -280,12 +280,17 @@ func (r *Runner) List(ctx context.Context, repo model.Repository, snapshot, path
|
||||
return items, scanner.Err()
|
||||
}
|
||||
|
||||
func (r *Runner) Restore(ctx context.Context, repo model.Repository, task model.RestoreTask) error {
|
||||
args := []string{"restore", task.SnapshotID, "--target", task.Target}
|
||||
func (r *Runner) Restore(ctx context.Context, repo model.Repository, task model.RestoreTask, progress ProgressCallback) error {
|
||||
args := []string{"restore", task.SnapshotID, "--target", task.Target, "--json"}
|
||||
for _, include := range task.Includes {
|
||||
args = append(args, "--include", include)
|
||||
}
|
||||
return r.run(ctx, repo, args, nil, nil)
|
||||
return r.run(ctx, repo, args, func(line []byte) {
|
||||
var status Progress
|
||||
if json.Unmarshal(line, &status) == nil && status.MessageType == "status" && progress != nil {
|
||||
progress(status)
|
||||
}
|
||||
}, nil)
|
||||
}
|
||||
|
||||
func (r *Runner) run(ctx context.Context, repo model.Repository, args []string, onLine func([]byte), capture *[]byte) error {
|
||||
|
||||
Reference in New Issue
Block a user