2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

debug: Support pack ID prefixes in debug examine

This commit is contained in:
Michael Eischer 2022-04-30 20:03:26 +02:00
parent 2d6a943911
commit 95bcc9ea31

View File

@ -427,12 +427,23 @@ func storePlainBlob(id restic.ID, prefix string, plain []byte) error {
} }
func runDebugExamine(gopts GlobalOptions, args []string) error { func runDebugExamine(gopts GlobalOptions, args []string) error {
repo, err := OpenRepository(gopts)
if err != nil {
return err
}
ids := make([]restic.ID, 0) ids := make([]restic.ID, 0)
for _, name := range args { for _, name := range args {
id, err := restic.ParseID(name) id, err := restic.ParseID(name)
if err != nil { if err != nil {
Warnf("error: %v\n", err) name, err = restic.Find(gopts.ctx, repo.Backend(), restic.PackFile, name)
continue if err == nil {
id, err = restic.ParseID(name)
}
if err != nil {
Warnf("error: %v\n", err)
continue
}
} }
ids = append(ids, id) ids = append(ids, id)
} }
@ -441,11 +452,6 @@ func runDebugExamine(gopts GlobalOptions, args []string) error {
return errors.Fatal("no pack files to examine") return errors.Fatal("no pack files to examine")
} }
repo, err := OpenRepository(gopts)
if err != nil {
return err
}
if !gopts.NoLock { if !gopts.NoLock {
lock, err := lockRepo(gopts.ctx, repo) lock, err := lockRepo(gopts.ctx, repo)
defer unlockRepo(lock) defer unlockRepo(lock)