Show restore progress details

This commit is contained in:
Mikei386
2026-06-21 22:59:56 +02:00
parent c014a5f502
commit 41ac4ba43e
10 changed files with 84 additions and 15 deletions
+8 -3
View File
@@ -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 {