From 29ead95c96536325a90cf2d8dc8d63ae03eba6b0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 29 Apr 2015 22:29:47 +0200 Subject: [PATCH] Adapt fsck command to packed blobs (unfinished) --- cmd/restic/cmd_fsck.go | 44 ++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/cmd/restic/cmd_fsck.go b/cmd/restic/cmd_fsck.go index aa7ded31d..eac4c4030 100644 --- a/cmd/restic/cmd_fsck.go +++ b/cmd/restic/cmd_fsck.go @@ -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") } }