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

Persist created and updated time in compose #1823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions fakestorage/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,7 @@ func TestServiceClientComposeObject(t *testing.T) {
)
u32Checksum := uint32Checksum([]byte(source1Content))
hash := checksum.MD5Hash([]byte(source1Content))
then := time.Now().Add(time.Duration(-1) * time.Minute)

objs := []Object{
{
Expand Down Expand Up @@ -2198,6 +2199,12 @@ func TestServiceClientComposeObject(t *testing.T) {
if attrs.ContentType != contentType {
t.Errorf("wrong content type\nwant %q\ngot %q", contentType, attrs.ContentType)
}
if then.After(attrs.Created) {
t.Errorf("wrong created time\nwant > %v\ngot: %v", then, attrs.Created)
}
if then.After(attrs.Updated) {
t.Errorf("wrong updated time\nwant > %v\ngot: %v", then, attrs.Updated)
}
if !bytes.Equal(attrs.MD5, expectedHash) {
t.Errorf("wrong hash returned\nwant %d\ngot %d", hash, attrs.MD5)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/backend/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,14 @@ func (s *storageFS) ComposeObject(bucketName string, objectNames []string, desti
sourceObjects = append(sourceObjects, obj)
}

now := time.Now().Format(timestampFormat)
dest := StreamingObject{
ObjectAttrs: ObjectAttrs{
BucketName: bucketName,
Name: destinationName,
ContentType: contentType,
Created: time.Now().String(),
Created: now,
Updated: now,
},
}

Expand Down
4 changes: 3 additions & 1 deletion internal/backend/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,14 @@ func (s *storageMemory) ComposeObject(bucketName string, objectNames []string, d
var dest Object
streamingDest, err := s.GetObject(bucketName, destinationName)
if err != nil {
now := time.Now().Format(timestampFormat)
dest = Object{
ObjectAttrs: ObjectAttrs{
BucketName: bucketName,
Name: destinationName,
ContentType: contentType,
Created: time.Now().String(),
Created: now,
Updated: now,
},
}
} else {
Expand Down