diff --git a/lib/go/camli/blobref/fetcher.go b/lib/go/camli/blobref/fetcher.go index 79cb73d00..51623eb18 100644 --- a/lib/go/camli/blobref/fetcher.go +++ b/lib/go/camli/blobref/fetcher.go @@ -178,3 +178,17 @@ func (s *MemoryStore) FetchStreaming(b *BlobRef) (file io.ReadCloser, size int64 } return ioutil.NopCloser(strings.NewReader(str)), int64(len(str)), nil } + +func SeekerFromStreamingFetcher(f StreamingFetcher) (SeekFetcher, os.Error) { + seeker, ok := f.(SeekFetcher) + if ok { + return seeker, nil + } + tester, ok := f.(SeekTester) + if ok { + if tester.IsFetcherASeeker() { + return &FetcherToSeekerWrapper{f}, nil + } + } + return nil, fmt.Errorf("bloref: TODO: SeekerFromStreamingFetcher: %T %v doesn't support seeking. TODO: wrap in a write-to-disk-and-read wrapper and/or cache", f, f) +} \ No newline at end of file diff --git a/server/go/camlistored/ui.go b/server/go/camlistored/ui.go index 9cc428ec5..68ad03c95 100644 --- a/server/go/camlistored/ui.go +++ b/server/go/camlistored/ui.go @@ -250,19 +250,7 @@ func (ui *UIHandler) serveUploadHelper(rw http.ResponseWriter, req *http.Request } func (ui *UIHandler) storageSeekFetcher() (blobref.SeekFetcher, os.Error) { - fetchSeeker, ok := ui.Storage.(blobref.SeekFetcher) - if ok { - return fetchSeeker, nil - } - tester, ok := ui.Storage.(blobref.SeekTester) - if ok { - if tester.IsFetcherASeeker() { - log.Printf("ui.Storage is a seeker; returning wrapper") - return &blobref.FetcherToSeekerWrapper{ui.Storage}, nil - } - } - return nil, fmt.Errorf("TODO: ui.Storage of %T %v doesn't support seeking. TODO: wrap in a cache", - ui.Storage, ui.Storage) + return blobref.SeekerFromStreamingFetcher(ui.Storage) } func (ui *UIHandler) serveDownload(rw http.ResponseWriter, req *http.Request) {