gofmt style changes only.

This commit is contained in:
Brad Fitzpatrick 2011-01-29 00:05:07 -08:00
parent 19d0934558
commit 749f73866d
8 changed files with 20 additions and 24 deletions

View File

@ -22,10 +22,10 @@ var flagRequestLog *bool = flag.Bool("reqlog", false, "Log incoming requests")
var blobFetcher blobref.Fetcher
func handleCamli(conn http.ResponseWriter, req *http.Request) {
handler := func (conn http.ResponseWriter, req *http.Request) {
handler := func(conn http.ResponseWriter, req *http.Request) {
httputil.BadRequestError(conn,
fmt.Sprintf("Unsupported path (%s) or method (%s).",
req.URL.Path, req.Method))
req.URL.Path, req.Method))
}
if *flagRequestLog {
log.Printf("%s %s", req.Method, req.RawURL)
@ -56,7 +56,7 @@ func handleCamli(conn http.ResponseWriter, req *http.Request) {
}
func handleRoot(conn http.ResponseWriter, req *http.Request) {
fmt.Fprintf(conn, "This is camlistored, a Camlistore storage daemon.\n");
fmt.Fprintf(conn, "This is camlistored, a Camlistore storage daemon.\n")
}
func main() {
@ -69,7 +69,6 @@ func main() {
os.Exit(1)
}
{
fi, err := os.Stat(*flagStorageRoot)
if err != nil || !fi.IsDirectory() {

View File

@ -81,12 +81,12 @@ func readBlobs(ch chan *blobInfo, blobPrefix, diskRoot, after string, remain *ui
continue
}
}
readBlobs(ch, newBlobPrefix, diskRoot + "/" + name, after, remain)
readBlobs(ch, newBlobPrefix, diskRoot+"/"+name, after, remain)
continue
}
if fi.IsRegular() && strings.HasSuffix(name, ".dat") {
blobName := name[0:len(name)-4]
blobName := name[0 : len(name)-4]
if blobName <= after {
continue
}
@ -118,7 +118,7 @@ func handleEnumerateBlobs(conn http.ResponseWriter, req *http.Request) {
fmt.Fprintf(conn, "{\n \"blobs\": [\n")
var after string
go readBlobs(ch, "", "", req.FormValue("after"), &limit);
go readBlobs(ch, "", "", req.FormValue("after"), &limit)
needsComma := false
for bi := range ch {
if bi == nil {
@ -129,7 +129,7 @@ func handleEnumerateBlobs(conn http.ResponseWriter, req *http.Request) {
break
}
blobName := bi.BlobRef.String()
if (needsComma) {
if needsComma {
fmt.Fprintf(conn, ",\n")
}
fmt.Fprintf(conn, " {\"blobRef\": \"%s\", \"size\": %d}",

View File

@ -40,7 +40,7 @@ func createGetHandler(fetcher blobref.Fetcher) func(http.ResponseWriter, *http.R
}
const fetchFailureDelayNs = 200e6 // 200 ms
const maxJsonSize = 64 * 1024 // should be enough for everyone
const maxJsonSize = 64 * 1024 // should be enough for everyone
func sendUnauthorized(conn http.ResponseWriter) {
conn.WriteHeader(http.StatusUnauthorized)
@ -134,15 +134,15 @@ func handleGet(conn http.ResponseWriter, req *http.Request, fetcher blobref.Fetc
slurpBytes, err := ioutil.ReadAll(lr)
if err != nil {
log.Printf("Fetch chain %d of %s failed in slurp: %v", i, br.String(), err)
sendUnauthorized(conn)
sendUnauthorized(conn)
return
}
saught := fetchChain[i+1].String()
if bytes.IndexAny(slurpBytes, saught) == -1 {
log.Printf("Fetch chain %d of %s failed; no reference to %s",
i, br.String(), saught)
sendUnauthorized(conn)
return
sendUnauthorized(conn)
return
}
}
}

View File

@ -62,4 +62,3 @@ func BlobFileName(b *blobref.BlobRef) string {
func BlobFromUrlPath(path string) *blobref.BlobRef {
return blobref.FromPattern(kGetPutPattern, path)
}

View File

@ -87,4 +87,3 @@ func handlePreUpload(conn http.ResponseWriter, req *http.Request) {
ret["alreadyHave"] = haveVector.Copy()
httputil.ReturnJson(conn, ret)
}

View File

@ -24,12 +24,12 @@ import (
// Default is {0, -1} to read all of a file.
type requestedRange struct {
SkipBytes int64
LimitBytes int64 // or -1 to read all
SkipBytes int64
LimitBytes int64 // or -1 to read all
}
func (rr *requestedRange) IsWholeFile() bool {
return rr.SkipBytes == 0 && rr.LimitBytes == -1;
return rr.SkipBytes == 0 && rr.LimitBytes == -1
}
var wholeRange = &requestedRange{0, -1}
@ -47,7 +47,7 @@ func getRequestedRange(req *http.Request) *requestedRange {
func getRequestedRangeFromString(rrange string) *requestedRange {
matches := rangePattern.FindStringSubmatch(rrange)
if len(matches) == 0 {
return wholeRange;
return wholeRange
}
skipBytes, _ := strconv.Atoi64(matches[1])
lastByteInclusive := int64(-1)

View File

@ -19,5 +19,5 @@ package main
import "testing"
func testRange(t *t.Testing) {
}

View File

@ -28,11 +28,11 @@ import (
"log"
"mime"
"os"
)
)
type receivedBlob struct {
blobRef *blobref.BlobRef
size int64
blobRef *blobref.BlobRef
size int64
}
var flagOpenImages *bool = flag.Bool("showimages", false, "Show images on receiving them with eog.")
@ -130,7 +130,7 @@ func handleMultiPartUpload(conn http.ResponseWriter, req *http.Request) {
func commonUploadResponse(req *http.Request) map[string]interface{} {
ret := make(map[string]interface{})
ret["maxUploadSize"] = 2147483647 // 2GB.. *shrug*
ret["maxUploadSize"] = 2147483647 // 2GB.. *shrug*
ret["uploadUrlExpirationSeconds"] = 86400
if len(req.Host) > 0 {
scheme := "http" // TODO: https
@ -229,4 +229,3 @@ func handlePut(conn http.ResponseWriter, req *http.Request) {
fmt.Fprint(conn, "OK")
}