2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-27 12:42:49 +00:00

Add repository.ListPack

This commit is contained in:
Alexander Neumann 2016-05-08 13:51:21 +02:00
parent 6fc3590838
commit 173940cbdf
2 changed files with 14 additions and 11 deletions

View File

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

View File

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