From 173940cbdf0bc5bde36247b7c2709ebfbf807270 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 8 May 2016 13:51:21 +0200 Subject: [PATCH] Add repository.ListPack --- src/cmds/restic/cmd_rebuild_index.go | 12 +----------- src/restic/repository/repository.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cmds/restic/cmd_rebuild_index.go b/src/cmds/restic/cmd_rebuild_index.go index e3e82684a..8ac54d80b 100644 --- a/src/cmds/restic/cmd_rebuild_index.go +++ b/src/cmds/restic/cmd_rebuild_index.go @@ -33,17 +33,7 @@ func loadBlobsFromPacks(repo *repository.Repository) (packs map[backend.ID][]pac defer close(done) f := func(job worker.Job, done <-chan struct{}) (interface{}, error) { - id := job.Data.(backend.ID) - - h := backend.Handle{Type: backend.Data, Name: id.String()} - rd := backend.NewReadSeeker(repo.Backend(), h) - - unpacker, err := pack.NewUnpacker(repo.Key(), rd) - if err != nil { - return nil, err - } - - return unpacker.Entries, nil + return repo.ListPack(job.Data.(backend.ID)) } jobCh := make(chan worker.Job) diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index 6df3471ff..aa75d322e 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -518,6 +518,19 @@ func (r *Repository) List(t backend.Type, done <-chan struct{}) <-chan backend.I return outCh } +// ListPack returns the list of blobs saved in the pack id. +func (r *Repository) ListPack(id backend.ID) ([]pack.Blob, error) { + h := backend.Handle{Type: backend.Data, Name: id.String()} + rd := backend.NewReadSeeker(r.Backend(), h) + + unpacker, err := pack.NewUnpacker(r.Key(), rd) + if err != nil { + return nil, err + } + + return unpacker.Entries, nil +} + // Delete calls backend.Delete() if implemented, and returns an error // otherwise. func (r *Repository) Delete() error {