(ctx context.Context, rep repo.Repository)
| 406 | } |
| 407 | |
| 408 | func (c *commandRestore) run(ctx context.Context, rep repo.Repository) error { |
| 409 | output, oerr := c.restoreOutput(ctx, rep) |
| 410 | if oerr != nil { |
| 411 | return errors.Wrap(oerr, "unable to initialize output") |
| 412 | } |
| 413 | |
| 414 | for _, rstp := range c.restores { |
| 415 | var rootEntry fs.Entry |
| 416 | |
| 417 | if rstp.isplaceholder { |
| 418 | re, err := c.setupPlaceholderExpansion(ctx, rep, rstp, output) |
| 419 | if err != nil { |
| 420 | return errors.Wrap(err, "placeholder can't be reified") |
| 421 | } |
| 422 | |
| 423 | rootEntry = re |
| 424 | } else { |
| 425 | source, err := c.tryToConvertPathToID(ctx, rep, rstp.source) |
| 426 | if err != nil { |
| 427 | return err |
| 428 | } |
| 429 | |
| 430 | re, err := snapshotfs.FilesystemEntryFromIDWithPath(ctx, rep, source, c.restoreConsistentAttributes) |
| 431 | if err != nil { |
| 432 | return errors.Wrap(err, "unable to get filesystem entry") |
| 433 | } |
| 434 | |
| 435 | rootEntry = re |
| 436 | } |
| 437 | |
| 438 | restoreProgress := c.getRestoreProgress() |
| 439 | progressCallback := func(_ context.Context, stats restore.Stats) { |
| 440 | restoreProgress.SetCounters(stats) |
| 441 | } |
| 442 | |
| 443 | st, err := restore.Entry(ctx, rep, output, rootEntry, restore.Options{ |
| 444 | Parallel: c.restoreParallel, |
| 445 | Incremental: c.restoreIncremental, |
| 446 | DeleteExtra: c.restoreDeleteExtra, |
| 447 | IgnoreErrors: c.restoreIgnoreErrors, |
| 448 | RestoreDirEntryAtDepth: c.restoreShallowAtDepth, |
| 449 | MinSizeForPlaceholder: c.minSizeForPlaceholder, |
| 450 | ProgressCallback: progressCallback, |
| 451 | }) |
| 452 | if err != nil { |
| 453 | return errors.Wrap(err, "error restoring") |
| 454 | } |
| 455 | |
| 456 | progressCallback(ctx, st) |
| 457 | restoreProgress.Flush() // Force last progress values to be printed |
| 458 | printRestoreStats(ctx, &st) |
| 459 | } |
| 460 | |
| 461 | return nil |
| 462 | } |
| 463 | |
| 464 | // tryToConvertPathToID checks if the source is a path and in this case returns the ID of the snapshot |
| 465 | // containing the latest version available. |
nothing calls this directly
no test coverage detected