mirror of https://github.com/perkeep/perkeep.git
Fix bugs in enumerate handler and s3's MaxEnumerateConfig.
Change-Id: Ib9cd52fe7d015a8c70416ec67ff6fd99a7a03d24
This commit is contained in:
parent
c83e29cfde
commit
d0af61a04a
|
@ -56,7 +56,7 @@ func handleEnumerateBlobs(conn http.ResponseWriter, req *http.Request, storage b
|
|||
formValueAfter := req.FormValue("after")
|
||||
|
||||
maxEnumerate := defaultMaxEnumerate
|
||||
if config, ok := storage.(blobserver.MaxEnumerateConfig); ok {
|
||||
if config, ok := blobserver.Unwrap(storage).(blobserver.MaxEnumerateConfig); ok {
|
||||
maxEnumerate = config.MaxEnumerate() - 1 // Since we'll add one below.
|
||||
}
|
||||
|
||||
|
|
|
@ -204,3 +204,14 @@ func MaybeWrapContext(sto Storage, req *http.Request) Storage {
|
|||
}
|
||||
return w.WrapContext(req)
|
||||
}
|
||||
|
||||
// Unwrap returns the wrapped Storage interface, if wrapped, else returns sto.
|
||||
func Unwrap(sto interface{}) interface{} {
|
||||
type get interface {
|
||||
GetStorage() Storage
|
||||
}
|
||||
if g, ok := sto.(get); ok {
|
||||
return Unwrap(g.GetStorage())
|
||||
}
|
||||
return sto
|
||||
}
|
|
@ -21,11 +21,14 @@ import (
|
|||
"time"
|
||||
|
||||
"camlistore.org/pkg/blobref"
|
||||
"camlistore.org/pkg/blobserver"
|
||||
)
|
||||
|
||||
var _ = log.Printf
|
||||
|
||||
func (sto *s3Storage) MaxEnumerate() uint { return 1000 }
|
||||
var _ blobserver.MaxEnumerateConfig = (*s3Storage)(nil)
|
||||
|
||||
func (sto *s3Storage) MaxEnumerate() int { return 1000 }
|
||||
|
||||
func (sto *s3Storage) EnumerateBlobs(dest chan<- blobref.SizedBlobRef, after string, limit int, wait time.Duration) error {
|
||||
defer close(dest)
|
||||
|
|
|
@ -100,6 +100,12 @@ func (s *storageAndConfig) Config() *blobserver.Config {
|
|||
return s.config
|
||||
}
|
||||
|
||||
// GetStorage returns the unwrapped blobserver.Storage interface value for
|
||||
// callers to type-assert optional interface implementations on. (e.g. EnumeratorConfig)
|
||||
func (s *storageAndConfig) GetStorage() blobserver.Storage {
|
||||
return s.Storage
|
||||
}
|
||||
|
||||
func handleCamliUsingStorage(conn http.ResponseWriter, req *http.Request, action string, storage blobserver.StorageConfiger) {
|
||||
handler := unsupportedHandler
|
||||
switch req.Method {
|
||||
|
|
Loading…
Reference in New Issue