diskpacked: finish enumeration bug with 'after' param

Change-Id: I391a33e7672cce6c7c9a4eebc0a09c2f03546b82
This commit is contained in:
Brad Fitzpatrick 2013-12-02 11:56:23 -08:00
parent d324eecaba
commit 6478e256f7
1 changed files with 8 additions and 3 deletions

View File

@ -269,14 +269,19 @@ func (s *storage) StatBlobs(dest chan<- blob.SizedRef, blobs []blob.Ref) (err er
func (s *storage) EnumerateBlobs(dest chan<- blob.SizedRef, after string, limit int) (err error) {
t := s.index.Find(after)
for i := 0; i < limit && t.Next(); {
br, ok := blob.Parse(t.Key())
key := t.Key()
if key <= after {
// EnumerateBlobs' semantics are '>', but sorted.KeyValue.Find is '>='.
continue
}
br, ok := blob.Parse(key)
if !ok {
err = fmt.Errorf("diskpacked: couldn't parse index key %q", t.Key())
err = fmt.Errorf("diskpacked: couldn't parse index key %q", key)
continue
}
m, ok := parseBlobMeta(t.Value())
if !ok {
err = fmt.Errorf("diskpacked: couldn't parse index value %q: %q", t.Key(), t.Value())
err = fmt.Errorf("diskpacked: couldn't parse index value %q: %q", key, t.Value())
continue
}
dest <- m.SizedRef(br)