1
0
mirror of https://github.com/restic/restic.git synced 2024-06-30 08:20:55 +02:00

Adapt fsck command to packed blobs (unfinished)

This commit is contained in:
Alexander Neumann 2015-04-29 22:29:47 +02:00
parent 60a0fe8349
commit 29ead95c96

View File

@ -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
}
}
} }
} }