From 1a8eee298a1fa28bf68dcbf916832b5517189c7e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 31 Dec 2012 17:36:28 -0800 Subject: [PATCH] Misc cleanups and TODOs Change-Id: I9903366427e41ebadba289bf66b294690675f78f --- pkg/blobserver/handlers/upload.go | 7 +++++-- pkg/blobserver/interface.go | 7 +++++++ pkg/blobserver/localdisk/receive.go | 5 ----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/blobserver/handlers/upload.go b/pkg/blobserver/handlers/upload.go index c1f688421..8245fa9fb 100644 --- a/pkg/blobserver/handlers/upload.go +++ b/pkg/blobserver/handlers/upload.go @@ -211,6 +211,9 @@ func handleMultiPartUpload(conn http.ResponseWriter, req *http.Request, blobRece } } + // TODO: wrap the mimePart reader in a LimitReader-ish + // wrapper, setting an error flag after reading + // blobserver.MaxBlobSize+1 bytes, then failing. blobGot, err := blobReceiver.ReceiveBlob(ref, mimePart) if err != nil { addError(fmt.Sprintf("Error receiving blob %v: %v\n", ref, err)) @@ -254,7 +257,7 @@ func handleMultiPartUpload(conn http.ResponseWriter, req *http.Request, blobRece func commonUploadResponse(configer blobserver.Configer, req *http.Request) (map[string]interface{}, error) { ret := make(map[string]interface{}) - ret["maxUploadSize"] = 2147483647 // 2GB.. *shrug*. TODO: cut this down, standardize + ret["maxUploadSize"] = blobserver.MaxBlobSize ret["uploadUrlExpirationSeconds"] = 86400 if configer == nil { @@ -281,7 +284,7 @@ func commonUploadResponse(configer blobserver.Configer, req *http.Request) (map[ } // NOTE: not part of the spec at present. old. might be re-introduced. -var kPutPattern *regexp.Regexp = regexp.MustCompile(`^/camli/([a-z0-9]+)-([a-f0-9]+)$`) +var kPutPattern = regexp.MustCompile(`^/camli/([a-z0-9]+)-([a-f0-9]+)$`) // NOTE: not part of the spec at present. old. might be re-introduced. func CreateNonStandardPutHandler(storage blobserver.Storage) func(http.ResponseWriter, *http.Request) { diff --git a/pkg/blobserver/interface.go b/pkg/blobserver/interface.go index 8918e1735..0e660668a 100644 --- a/pkg/blobserver/interface.go +++ b/pkg/blobserver/interface.go @@ -26,6 +26,13 @@ import ( "camlistore.org/pkg/blobref" ) +// MaxBlobSize is the size of a single blob in Camlistore. +// +// TODO: formalize this in the specs. This value of 16 MB is less than +// App Engine's 32 MB request limit, much more than Venti's limit, and +// much more than the ~64 KB & 256 KB chunks that the FileWriter make +const MaxBlobSize = 16 << 20 + var ErrCorruptBlob = errors.New("corrupt blob; digest doesn't match") type BlobReceiver interface { diff --git a/pkg/blobserver/localdisk/receive.go b/pkg/blobserver/localdisk/receive.go index ed216d035..d3841fa89 100644 --- a/pkg/blobserver/localdisk/receive.go +++ b/pkg/blobserver/localdisk/receive.go @@ -23,7 +23,6 @@ import ( "io/ioutil" "log" "os" - "os/exec" "path/filepath" "camlistore.org/pkg/blobref" @@ -118,10 +117,6 @@ func (ds *DiskStorage) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) ( blobGot = blobref.SizedBlobRef{BlobRef: blobRef, Size: stat.Size()} success = true - if os.Getenv("CAMLI_HACK_OPEN_IMAGES") == "1" { - exec.Command("eog", fileName).Run() - } - hub := ds.GetBlobHub() hub.NotifyBlobReceived(blobRef) for _, mirror := range ds.mirrorPartitions {