mirror of
https://github.com/distribution/distribution.git
synced 2025-06-26 23:39:39 +00:00
Enable MD5 check on GCS driver
Apparently you can upload 0-size content wihtout GCS reportin any errors back to you. This is something a lot of our users experienced and reported. See here for at least one example: github.com/distribution/distribution/issues/3018 This sets tbe MD5 sum on the uploaded content which should rectify things according to the docs: https://pkg.go.dev/cloud.google.com/go/storage#ObjectAttrs Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
parent
d9b0802d81
commit
e20645c050
@ -14,6 +14,7 @@ package gcs
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -425,6 +426,10 @@ func (d *driver) putContent(ctx context.Context, obj *storage.ObjectHandle, cont
|
||||
if _, err := bytes.NewReader(content).WriteTo(wc); err != nil {
|
||||
return err
|
||||
}
|
||||
h := md5.New()
|
||||
h.Write(content)
|
||||
wc.MD5 = h.Sum(nil)
|
||||
|
||||
return wc.Close()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user