mirror of https://github.com/perkeep/perkeep.git
Rename blobref.Fetcher to blobref.SeekFetcher
This commit is contained in:
parent
0df00167ec
commit
59e577c023
|
@ -23,7 +23,7 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
func NewCachingFetcher(cacheTarget blobserver.Cache, sfetcher blobref.StreamingFetcher) blobref.Fetcher {
|
||||
func NewCachingFetcher(cacheTarget blobserver.Cache, sfetcher blobref.StreamingFetcher) blobref.SeekFetcher {
|
||||
return &CachingFetcher{cacheTarget, sfetcher}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ var _ = log.Println
|
|||
type CamliFileSystem struct {
|
||||
fuse.DefaultPathFilesystem
|
||||
|
||||
fetcher blobref.Fetcher
|
||||
fetcher blobref.SeekFetcher
|
||||
root *blobref.BlobRef
|
||||
|
||||
blobToSchema *lru.Cache // ~map[blobstring]*schema.Superset
|
||||
|
@ -46,7 +46,7 @@ type CamliFileSystem struct {
|
|||
nameToAttr *lru.Cache // ~map[string]*fuse.Attr
|
||||
}
|
||||
|
||||
func NewCamliFileSystem(fetcher blobref.Fetcher, root *blobref.BlobRef) *CamliFileSystem {
|
||||
func NewCamliFileSystem(fetcher blobref.SeekFetcher, root *blobref.BlobRef) *CamliFileSystem {
|
||||
return &CamliFileSystem{
|
||||
fetcher: fetcher,
|
||||
blobToSchema: lru.New(1024), // arbitrary; TODO: tunable/smarter?
|
||||
|
|
|
@ -32,13 +32,12 @@ import (
|
|||
|
||||
var _ = log.Printf
|
||||
|
||||
// TODO: rename StreamingFetcher to be Fetch (the common case) and
|
||||
// make a new interface for FetchSeeker (the rare case)
|
||||
// TODO: rename StreamingFetcher to be Fetcher (the common case)
|
||||
|
||||
// TODO: add FetcherAt / FetchAt (for HTTP range requests). But then how
|
||||
// to make all FetchSeeker also be a FetchAt? By hand?
|
||||
// to make all SeekFetcer also be a FetchAt? By hand?
|
||||
|
||||
type Fetcher interface {
|
||||
type SeekFetcher interface {
|
||||
// Fetch returns a blob. If the blob is not found then
|
||||
// os.ENOENT should be returned for the error (not a wrapped
|
||||
// error with a ENOENT inside)
|
||||
|
@ -52,7 +51,7 @@ type StreamingFetcher interface {
|
|||
FetchStreaming(*BlobRef) (file io.ReadCloser, size int64, err os.Error)
|
||||
}
|
||||
|
||||
func NewSerialFetcher(fetchers ...Fetcher) Fetcher {
|
||||
func NewSerialFetcher(fetchers ...SeekFetcher) SeekFetcher {
|
||||
return &serialFetcher{fetchers}
|
||||
}
|
||||
|
||||
|
@ -70,7 +69,7 @@ func NewConfigDirFetcher() *DirFetcher {
|
|||
}
|
||||
|
||||
type serialFetcher struct {
|
||||
fetchers []Fetcher
|
||||
fetchers []SeekFetcher
|
||||
}
|
||||
|
||||
func (sf *serialFetcher) Fetch(b *BlobRef) (file ReadSeekCloser, size int64, err os.Error) {
|
||||
|
|
|
@ -75,7 +75,7 @@ type BlobEnumerator interface {
|
|||
|
||||
// Cache is the minimal interface expected of a blob cache.
|
||||
type Cache interface {
|
||||
blobref.Fetcher
|
||||
blobref.SeekFetcher // TODO: change this to be just a normal StreamingFetcher
|
||||
BlobReceiver
|
||||
BlobStatter
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ func SignerPublicKeyBlobref() *blobref.BlobRef {
|
|||
return br
|
||||
}
|
||||
|
||||
func (c *Client) GetBlobFetcher() blobref.Fetcher {
|
||||
func (c *Client) GetBlobFetcher() blobref.SeekFetcher {
|
||||
// Use blobref.NewSeriesFetcher(...all configured fetch paths...)
|
||||
return blobref.NewConfigDirFetcher()
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ func (sr *SignRequest) Sign() (signedJson string, err os.Error) {
|
|||
|
||||
var pubkeyReader io.ReadCloser
|
||||
switch fetcher := sr.Fetcher.(type) {
|
||||
case blobref.Fetcher:
|
||||
case blobref.SeekFetcher:
|
||||
pubkeyReader, _, err = fetcher.Fetch(signerBlob)
|
||||
case blobref.StreamingFetcher:
|
||||
pubkeyReader, _, err = fetcher.FetchStreaming(signerBlob)
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
var _ = log.Printf
|
||||
|
||||
type FileReader struct {
|
||||
fetcher blobref.Fetcher
|
||||
fetcher blobref.SeekFetcher
|
||||
ss *Superset
|
||||
ci int // index into contentparts
|
||||
ccon uint64 // bytes into current chunk already consumed
|
||||
|
@ -38,7 +38,7 @@ type FileReader struct {
|
|||
}
|
||||
|
||||
// TODO: make this take a blobref.FetcherAt instead?
|
||||
func NewFileReader(fetcher blobref.Fetcher, fileBlobRef *blobref.BlobRef) (*FileReader, os.Error) {
|
||||
func NewFileReader(fetcher blobref.SeekFetcher, fileBlobRef *blobref.BlobRef) (*FileReader, os.Error) {
|
||||
ss := new(Superset)
|
||||
rsc, _, err := fetcher.Fetch(fileBlobRef)
|
||||
if err != nil {
|
||||
|
@ -53,7 +53,7 @@ func NewFileReader(fetcher blobref.Fetcher, fileBlobRef *blobref.BlobRef) (*File
|
|||
return ss.NewFileReader(fetcher), nil
|
||||
}
|
||||
|
||||
func (ss *Superset) NewFileReader(fetcher blobref.Fetcher) *FileReader {
|
||||
func (ss *Superset) NewFileReader(fetcher blobref.SeekFetcher) *FileReader {
|
||||
// TODO: return an error if ss isn't a Type "file" ?
|
||||
// TODO: return some error if the redundant ss.Size field doesn't match ContentParts?
|
||||
return &FileReader{fetcher: fetcher, ss: ss}
|
||||
|
|
|
@ -236,7 +236,7 @@ func (ui *UIHandler) serveDownload(rw http.ResponseWriter, req *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
fetchSeeker, ok := ui.Storage.(blobref.Fetcher)
|
||||
fetchSeeker, ok := ui.Storage.(blobref.SeekFetcher)
|
||||
if !ok {
|
||||
// TODO: wrap ui.Storage in disk-caching wrapper so it can seek
|
||||
http.Error(rw, "TODO: configured BlobRoot doesn't support seeking and disk cache wrapping not yet implemented", 500)
|
||||
|
|
Loading…
Reference in New Issue