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,13 +88,17 @@ func handleHTTP(w http.ResponseWriter, req *http.Request) {
log.Print("upload SHA1: ", sha1Hex)
reqSHA1 := req.Header.Get("X-Content-SHA1")
if reqSHA1 != "" && reqSHA1 != sha1Hex {
if reqSHA1 != "" {
if reqSHA1 != sha1Hex {
err = fmt.Errorf("upload SHA1 does not match given SHA1: %s", reqSHA1)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error() + "\n"))
return
}
log.Print("upload SHA1 is as expected")
}
os.Rename(tmpOut, filePath)
if err := ioutil.WriteFile(filePath+".sha1", []byte(sha1Hex), 0644); err != nil {