mirror of https://github.com/restic/restic.git
Merge pull request #1942 from mholt/statserr
stats: Improve error message for bad snapshot ID (fixes #1933)
This commit is contained in:
commit
abc923f693
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
"github.com/restic/restic/internal/walker"
|
"github.com/restic/restic/internal/walker"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -95,18 +96,18 @@ func runStats(gopts GlobalOptions, args []string) error {
|
||||||
if snapshotIDString == "latest" {
|
if snapshotIDString == "latest" {
|
||||||
sID, err = restic.FindLatestSnapshot(ctx, repo, []string{}, []restic.TagList{}, snapshotByHost)
|
sID, err = restic.FindLatestSnapshot(ctx, repo, []string{}, []restic.TagList{}, snapshotByHost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exitf(1, "latest snapshot for criteria not found: %v", err)
|
return errors.Fatalf("latest snapshot for criteria not found: %v", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sID, err = restic.FindSnapshot(repo, snapshotIDString)
|
sID, err = restic.FindSnapshot(repo, snapshotIDString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Fatalf("error loading snapshot: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot, err := restic.LoadSnapshot(ctx, repo, sID)
|
snapshot, err := restic.LoadSnapshot(ctx, repo, sID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return errors.Fatalf("error loading snapshot from repo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = statsWalkSnapshot(ctx, snapshot, repo, stats)
|
err = statsWalkSnapshot(ctx, snapshot, repo, stats)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
// ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix
|
// ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix
|
||||||
// could be found.
|
// could be found.
|
||||||
var ErrNoIDPrefixFound = errors.New("no ID found")
|
var ErrNoIDPrefixFound = errors.New("no matching ID found")
|
||||||
|
|
||||||
// ErrMultipleIDMatches is returned by Find() when multiple IDs with the given
|
// ErrMultipleIDMatches is returned by Find() when multiple IDs with the given
|
||||||
// prefix are found.
|
// prefix are found.
|
||||||
|
|
Loading…
Reference in New Issue