diff --git a/clients/go/camsync/camsync.go b/clients/go/camsync/camsync.go index 7dbe51b42..2b4f1e006 100644 --- a/clients/go/camsync/camsync.go +++ b/clients/go/camsync/camsync.go @@ -17,12 +17,15 @@ limitations under the License. package main import ( - "camli/blobref" - "camli/client" "flag" "fmt" "log" + "io" "os" + "strings" + + "camli/blobref" + "camli/client" ) // Things that can be uploaded. (at most one of these) @@ -121,7 +124,12 @@ func doPass(sc, dc *client.Client, passNum int) (retErr os.Error) { for sb := range destNotHaveBlobs { fmt.Printf("Destination needs blob: %s\n", sb) - blobReader, size, err := sc.FetchStreaming(sb.BlobRef) + var ( + blobReader io.Reader + size int64 + err os.Error + ) + blobReader, size, err = sc.FetchStreaming(sb.BlobRef) if err != nil { errorCount++ log.Printf("Error fetching %s: %v", sb.BlobRef, err) @@ -133,6 +141,11 @@ func doPass(sc, dc *client.Client, passNum int) (retErr os.Error) { sb.Size, sb.BlobRef, size) continue } + if size == 0 { + // Hack. + // TODO-GO: fix http? + blobReader = strings.NewReader("") + } uh := &client.UploadHandle{BlobRef: sb.BlobRef, Size: size, Contents: blobReader} pr, err := dc.Upload(uh) if err != nil { diff --git a/lib/go/camli/blobserver/handlers/upload.go b/lib/go/camli/blobserver/handlers/upload.go index 92d780332..0cb1e1443 100644 --- a/lib/go/camli/blobserver/handlers/upload.go +++ b/lib/go/camli/blobserver/handlers/upload.go @@ -54,7 +54,7 @@ func handleMultiPartUpload(conn http.ResponseWriter, req *http.Request, blobRece var errText string addError := func(s string) { - log.Printf("Client error: %s", s) + log.Printf("handlers/upload: client error: %s", s) if errText == "" { errText = s return diff --git a/lib/go/camli/client/upload.go b/lib/go/camli/client/upload.go index 04e643e15..a3765e85b 100644 --- a/lib/go/camli/client/upload.go +++ b/lib/go/camli/client/upload.go @@ -302,6 +302,7 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, os.Error) { req.TransferEncoding = nil resp, err = c.httpClient.Do(req) if err != nil { + log.Printf("client/upload: http write error: %v", err) return error("upload http error: %v", err) } diff --git a/lib/go/camli/mysqlindexer/receive.go b/lib/go/camli/mysqlindexer/receive.go index 6597b5005..a4b61e3e0 100644 --- a/lib/go/camli/mysqlindexer/receive.go +++ b/lib/go/camli/mysqlindexer/receive.go @@ -96,7 +96,7 @@ func (mi *Indexer) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (rets hash := blobRef.Hash() var written int64 written, err = io.Copy(io.MultiWriter(hash, sniffer), source) - log.Printf("mysqlindexer: wrote %d; err %v", written, err) + log.Printf("mysqlindexer/receive: copied to hash/sniffer %d; err %v", written, err) if err != nil { return } @@ -108,7 +108,7 @@ func (mi *Indexer) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (rets sniffer.Parse() mimeType := sniffer.MimeType() - log.Printf("Read %d bytes; type=%v; truncated=%v", written, sniffer.IsTruncated()) + log.Printf("mysqlindexer/receive: Read %d bytes; type=%v; truncated=%v", written, sniffer.IsTruncated()) var client *mysql.Client if client, err = mi.getConnection(); err != nil {