mirror of
https://github.com/octoleo/restic.git
synced 2024-11-10 15:21:03 +00:00
Merge pull request #641 from restic/fix-640
Improve error message for 'forget'
This commit is contained in:
commit
974f2f78a9
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"restic"
|
"restic"
|
||||||
@ -116,11 +117,24 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// first, process all snapshot IDs given as arguments
|
// parse arguments as hex strings
|
||||||
|
var ids []string
|
||||||
for _, s := range args {
|
for _, s := range args {
|
||||||
|
_, err := hex.DecodeString(s)
|
||||||
|
if err != nil {
|
||||||
|
Warnf("argument %q is not a snapshot ID, ignoring\n", s)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
ids = append(ids, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// process all snapshot IDs given as arguments
|
||||||
|
for _, s := range ids {
|
||||||
id, err := restic.FindSnapshot(repo, s)
|
id, err := restic.FindSnapshot(repo, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
Warnf("cound not find a snapshot for ID %q, ignoring\n", s)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !opts.DryRun {
|
if !opts.DryRun {
|
||||||
|
Loading…
Reference in New Issue
Block a user