Stream snapshot file listings

This commit is contained in:
Mikei386
2026-07-10 12:41:48 +02:00
parent c2f0f0b277
commit f22c2e462d
10 changed files with 59 additions and 19 deletions
+8 -9
View File
@@ -274,20 +274,16 @@ func (r *Runner) List(ctx context.Context, repo model.Repository, snapshot, path
if path != "" {
args = append(args, path)
}
var output []byte
if err := r.run(ctx, repo, args, nil, &output); err != nil {
return nil, err
}
items := []map[string]any{}
scanner := bufio.NewScanner(strings.NewReader(string(output)))
scanner.Buffer(make([]byte, 0, 64*1024), 2*1024*1024)
for scanner.Scan() {
if err := r.run(ctx, repo, args, func(line []byte) {
var item map[string]any
if json.Unmarshal(scanner.Bytes(), &item) == nil && item["struct_type"] == "node" {
if json.Unmarshal(line, &item) == nil && item["struct_type"] == "node" {
items = append(items, item)
}
}, nil); err != nil {
return nil, err
}
return items, scanner.Err()
return items, nil
}
func (r *Runner) Diff(ctx context.Context, repo model.Repository, before, after string, limit int) (DiffResult, error) {
@@ -466,6 +462,9 @@ func (r *Runner) runWithInputEnvPassword(ctx context.Context, repo model.Reposit
if errors.Is(ctx.Err(), context.Canceled) {
return fmt.Errorf("cancelled: %w", ctx.Err())
}
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
return fmt.Errorf("environment: Restic-Aufruf hat das Zeitlimit überschritten: %w", ctx.Err())
}
return resticError(message, err)
}
return nil