store: log when upload SHA1 is ok

This commit is contained in:
Mikaël Cluseau 2019-10-16 18:24:28 +11:00
parent 48ab32f319
commit 4b0f5dca84

View File

@ -88,11 +88,15 @@ func handleHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("upload SHA1: ", sha1Hex) log.Print("upload SHA1: ", sha1Hex)
reqSHA1 := req.Header.Get("X-Content-SHA1") reqSHA1 := req.Header.Get("X-Content-SHA1")
if reqSHA1 != "" && reqSHA1 != sha1Hex { if reqSHA1 != "" {
err = fmt.Errorf("upload SHA1 does not match given SHA1: %s", reqSHA1) if reqSHA1 != sha1Hex {
w.WriteHeader(http.StatusBadRequest) err = fmt.Errorf("upload SHA1 does not match given SHA1: %s", reqSHA1)
w.Write([]byte(err.Error() + "\n")) w.WriteHeader(http.StatusBadRequest)
return w.Write([]byte(err.Error() + "\n"))
return
}
log.Print("upload SHA1 is as expected")
} }
os.Rename(tmpOut, filePath) os.Rename(tmpOut, filePath)