Stream snapshot file listings
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user