Misc cleanups and TODOs

Change-Id: I9903366427e41ebadba289bf66b294690675f78f
This commit is contained in:
Brad Fitzpatrick 2012-12-31 17:36:28 -08:00
parent e01b19fb32
commit 1a8eee298a
3 changed files with 12 additions and 7 deletions

View File

@ -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) blobGot, err := blobReceiver.ReceiveBlob(ref, mimePart)
if err != nil { if err != nil {
addError(fmt.Sprintf("Error receiving blob %v: %v\n", ref, err)) 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) { func commonUploadResponse(configer blobserver.Configer, req *http.Request) (map[string]interface{}, error) {
ret := make(map[string]interface{}) ret := make(map[string]interface{})
ret["maxUploadSize"] = 2147483647 // 2GB.. *shrug*. TODO: cut this down, standardize ret["maxUploadSize"] = blobserver.MaxBlobSize
ret["uploadUrlExpirationSeconds"] = 86400 ret["uploadUrlExpirationSeconds"] = 86400
if configer == nil { 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. // 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. // NOTE: not part of the spec at present. old. might be re-introduced.
func CreateNonStandardPutHandler(storage blobserver.Storage) func(http.ResponseWriter, *http.Request) { func CreateNonStandardPutHandler(storage blobserver.Storage) func(http.ResponseWriter, *http.Request) {

View File

@ -26,6 +26,13 @@ import (
"camlistore.org/pkg/blobref" "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") var ErrCorruptBlob = errors.New("corrupt blob; digest doesn't match")
type BlobReceiver interface { type BlobReceiver interface {

View File

@ -23,7 +23,6 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"camlistore.org/pkg/blobref" "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()} blobGot = blobref.SizedBlobRef{BlobRef: blobRef, Size: stat.Size()}
success = true success = true
if os.Getenv("CAMLI_HACK_OPEN_IMAGES") == "1" {
exec.Command("eog", fileName).Run()
}
hub := ds.GetBlobHub() hub := ds.GetBlobHub()
hub.NotifyBlobReceived(blobRef) hub.NotifyBlobReceived(blobRef)
for _, mirror := range ds.mirrorPartitions { for _, mirror := range ds.mirrorPartitions {