forked from TrueCloudLab/restic
Adapt fsck command to packed blobs (unfinished)
This commit is contained in:
parent
60a0fe8349
commit
29ead95c96
1 changed files with 15 additions and 29 deletions
|
@ -245,40 +245,26 @@ func (cmd CmdFsck) Execute(args []string) error {
|
||||||
|
|
||||||
debug.Log("restic.fsck", "starting orphaned check\n")
|
debug.Log("restic.fsck", "starting orphaned check\n")
|
||||||
|
|
||||||
l := []struct {
|
cnt := make(map[pack.BlobType]*backend.IDSet)
|
||||||
desc string
|
cnt[pack.Data] = backend.NewIDSet()
|
||||||
tpe backend.Type
|
cnt[pack.Tree] = backend.NewIDSet()
|
||||||
set *backend.IDSet
|
|
||||||
}{
|
|
||||||
{"data blob", backend.Data, cmd.o_data},
|
|
||||||
{"tree", backend.Tree, cmd.o_trees},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, d := range l {
|
for blob := range s.Index().Each(done) {
|
||||||
debug.Log("restic.fsck", "checking for orphaned %v\n", d.desc)
|
fmt.Println(blob.ID)
|
||||||
|
|
||||||
done := make(chan struct{})
|
err = cnt[blob.Type].Find(blob.ID)
|
||||||
|
if err != nil {
|
||||||
for name := range s.List(d.tpe, done) {
|
if !cmd.RemoveOrphaned {
|
||||||
id, err := backend.ParseID(name)
|
fmt.Printf("orphaned %v blob %v\n", blob.Type, blob.ID)
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "invalid id for %v: %v\n", d.tpe, name)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = d.set.Find(id)
|
fmt.Printf("removing orphaned %v blob %v\n", blob.Type, blob.ID)
|
||||||
if err != nil {
|
// err := s.Remove(d.tpe, name)
|
||||||
if !cmd.RemoveOrphaned {
|
// if err != nil {
|
||||||
fmt.Printf("orphaned %v %v\n", d.desc, id)
|
// return err
|
||||||
continue
|
// }
|
||||||
}
|
return errors.New("not implemented")
|
||||||
|
|
||||||
fmt.Printf("removing orphaned %v %v\n", d.desc, id)
|
|
||||||
err := s.Remove(d.tpe, name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue