schema: make serverHasBlob just use blobserver.StatBlob

Change-Id: I3012763660c9ed87eb48b2d95b8265c3c77f32df
This commit is contained in:
Brad Fitzpatrick 2013-02-02 21:50:03 -08:00
parent 96ea9af952
commit 6a4eff5b84
1 changed files with 5 additions and 6 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt"
"io"
"log"
"os"
"strings"
"camlistore.org/pkg/blobref"
@ -137,13 +138,11 @@ func writeFileMapOld(bs blobserver.StatReceiver, file *Builder, r io.Reader) (*b
}
func serverHasBlob(bs blobserver.BlobStatter, br *blobref.BlobRef) (have bool, err error) {
ch := make(chan blobref.SizedBlobRef, 1)
go func() {
err = bs.StatBlobs(ch, []*blobref.BlobRef{br}, 0)
close(ch)
}()
for _ = range ch {
_, err = blobserver.StatBlob(bs, br)
if err == nil {
have = true
} else if err == os.ErrNotExist {
err = nil
}
return
}