Add repository.ListPack
This commit is contained in:
parent
6fc3590838
commit
173940cbdf
2 changed files with 14 additions and 11 deletions
|
@ -33,17 +33,7 @@ func loadBlobsFromPacks(repo *repository.Repository) (packs map[backend.ID][]pac
|
||||||
defer close(done)
|
defer close(done)
|
||||||
|
|
||||||
f := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
|
f := func(job worker.Job, done <-chan struct{}) (interface{}, error) {
|
||||||
id := job.Data.(backend.ID)
|
return repo.ListPack(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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jobCh := make(chan worker.Job)
|
jobCh := make(chan worker.Job)
|
||||||
|
|
|
@ -518,6 +518,19 @@ func (r *Repository) List(t backend.Type, done <-chan struct{}) <-chan backend.I
|
||||||
return outCh
|
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
|
// Delete calls backend.Delete() if implemented, and returns an error
|
||||||
// otherwise.
|
// otherwise.
|
||||||
func (r *Repository) Delete() error {
|
func (r *Repository) Delete() error {
|
||||||
|
|
Loading…
Reference in a new issue