mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +00:00
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")
|
||||
|
||||
l := []struct {
|
||||
desc string
|
||||
tpe backend.Type
|
||||
set *backend.IDSet
|
||||
}{
|
||||
{"data blob", backend.Data, cmd.o_data},
|
||||
{"tree", backend.Tree, cmd.o_trees},
|
||||
}
|
||||
cnt := make(map[pack.BlobType]*backend.IDSet)
|
||||
cnt[pack.Data] = backend.NewIDSet()
|
||||
cnt[pack.Tree] = backend.NewIDSet()
|
||||
|
||||
for _, d := range l {
|
||||
debug.Log("restic.fsck", "checking for orphaned %v\n", d.desc)
|
||||
for blob := range s.Index().Each(done) {
|
||||
fmt.Println(blob.ID)
|
||||
|
||||
done := make(chan struct{})
|
||||
|
||||
for name := range s.List(d.tpe, done) {
|
||||
id, err := backend.ParseID(name)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "invalid id for %v: %v\n", d.tpe, name)
|
||||
err = cnt[blob.Type].Find(blob.ID)
|
||||
if err != nil {
|
||||
if !cmd.RemoveOrphaned {
|
||||
fmt.Printf("orphaned %v blob %v\n", blob.Type, blob.ID)
|
||||
continue
|
||||
}
|
||||
|
||||
err = d.set.Find(id)
|
||||
if err != nil {
|
||||
if !cmd.RemoveOrphaned {
|
||||
fmt.Printf("orphaned %v %v\n", d.desc, id)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("removing orphaned %v %v\n", d.desc, id)
|
||||
err := s.Remove(d.tpe, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Printf("removing orphaned %v blob %v\n", blob.Type, blob.ID)
|
||||
// err := s.Remove(d.tpe, name)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
return errors.New("not implemented")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue