(ctx context.Context, f fs.File, fname string)
| 368 | } |
| 369 | |
| 370 | func downloadFile(ctx context.Context, f fs.File, fname string) error { |
| 371 | if err := os.MkdirAll(filepath.Dir(fname), dirMode); err != nil { |
| 372 | return errors.Wrap(err, "error making directory") |
| 373 | } |
| 374 | |
| 375 | src, err := f.Open(ctx) |
| 376 | if err != nil { |
| 377 | return errors.Wrap(err, "error opening object") |
| 378 | } |
| 379 | defer src.Close() //nolint:errcheck |
| 380 | |
| 381 | dst, err := os.Create(fname) //nolint:gosec |
| 382 | if err != nil { |
| 383 | return errors.Wrap(err, "error creating file to edit") |
| 384 | } |
| 385 | |
| 386 | defer dst.Close() //nolint:errcheck |
| 387 | |
| 388 | return errors.Wrap(iocopy.JustCopy(dst, src), "error downloading file") |
| 389 | } |
| 390 | |
| 391 | // Stats returns aggregated statistics computed during snapshot comparison |
| 392 | // must be invoked after a call to Compare which populates ComparerStats struct. |
no test coverage detected