mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Merge pull request #641 from restic/fix-640
Improve error message for 'forget'
This commit is contained in:
commit
974f2f78a9
1 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"restic"
|
||||
|
@ -116,11 +117,24 @@ func runForget(opts ForgetOptions, gopts GlobalOptions, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// first, process all snapshot IDs given as arguments
|
||||
// parse arguments as hex strings
|
||||
var ids []string
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
Warnf("cound not find a snapshot for ID %q, ignoring\n", s)
|
||||
continue
|
||||
}
|
||||
|
||||
if !opts.DryRun {
|
||||
|
|
Loading…
Reference in a new issue