From bf8f4b2423620bffe431fa2612c110035b89a59b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 17 Mar 2014 23:02:01 -0700 Subject: [PATCH] sync: fix bug in prefix enumeration. could send one extra item. Depending on timing, could lead to ListMissingDestinationBlobs getting out of sync and causing a lot of blobs to be replicated that were fine and already on the server. Change-Id: I3710e59088f1fe4e526f8f11bc9d1837a727e512 --- pkg/server/sync.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/server/sync.go b/pkg/server/sync.go index fb78f20f2..0dc3659c1 100644 --- a/pkg/server/sync.go +++ b/pkg/server/sync.go @@ -740,13 +740,13 @@ func (sh *SyncHandler) startValidatePrefix(ctx *context.Context, pfx string, doD go func() { defer close(c) err := blobserver.EnumerateAllFrom(ctx, e, pfx, func(sb blob.SizedRef) error { + // TODO: could add a more efficient method on blob.Ref to do this, + // that doesn't involve call String(). + if !strings.HasPrefix(sb.Ref.String(), pfx) { + return errNotPrefix + } select { case c <- sb: - // TODO: could add a more efficient method on blob.Ref to do this, - // that doesn't involve call String(). - if !strings.HasPrefix(sb.Ref.String(), pfx) { - return errNotPrefix - } sh.mu.Lock() if doDest { sh.vdestCount++