Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return attrs for newly created object in rewrite #823

Merged
merged 3 commits into from Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions fakestorage/object.go
Expand Up @@ -624,12 +624,12 @@ func (s *Server) rewriteObject(r *http.Request) jsonResponse {
Content: append([]byte(nil), obj.Content...),
}

_, err = s.createObject(newObject)
created, err := s.createObject(newObject)
if err != nil {
return errToJsonResponse(err)
}

return jsonResponse{data: newObjectRewriteResponse(newObject.ObjectAttrs)}
return jsonResponse{data: newObjectRewriteResponse(created.ObjectAttrs)}
}

func (s *Server) downloadObject(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 6 additions & 0 deletions fakestorage/object_test.go
Expand Up @@ -1136,6 +1136,9 @@ func TestServiceClientRewriteObject(t *testing.T) {
if !bytes.Equal(attrs.MD5, hash) {
t.Errorf("wrong hash returned\nwant %d\ngot %d", hash, attrs.MD5)
}
if attrs.Generation == 0 {
t.Errorf("Generation was zero, expected non-zero")
}
obj, err := server.GetObject(test.bucketName, test.objectName)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -1268,6 +1271,9 @@ func TestServiceClientRewriteObjectWithGenerations(t *testing.T) {
if !bytes.Equal(attrs.MD5, expectedHash) {
t.Errorf("wrong hash returned\nwant %d\ngot %d", expectedHash, attrs.MD5)
}
if attrs.Generation == 0 {
t.Errorf("Generation was zero, expected non-zero")
}
obj, err := server.GetObject(test.bucketName, test.objectName)
if err != nil {
t.Fatal(err)
Expand Down