diff --git a/internal/test/e2e/s3_test.go b/internal/test/e2e/s3_test.go index bb9745d51..cb4c7cd60 100644 --- a/internal/test/e2e/s3_test.go +++ b/internal/test/e2e/s3_test.go @@ -499,6 +499,13 @@ func TestS3List(t *testing.T) { if !cmp.Equal(test.want, got) { t.Errorf("test %d: unexpected response, want %v got %v", i, test.want, got) } + for _, obj := range result.Contents { + if obj.ETag == "" { + t.Fatal("expected non-empty ETag") + } else if obj.LastModified.IsZero() { + t.Fatal("expected non-zero LastModified") + } + } } } diff --git a/stores/metadata.go b/stores/metadata.go index cfcde4744..0733ad567 100644 --- a/stores/metadata.go +++ b/stores/metadata.go @@ -2894,7 +2894,7 @@ func (s *SQLStore) ListObjects(ctx context.Context, bucket, prefix, sortBy, sort } var rows []rawObjectMetadata if err := s.db. - Select("o.object_id as Name, o.size as Size, o.health as Health, o.mime_type as mimeType, o.created_at as ModTime"). + Select("o.object_id as Name, o.size as Size, o.health as Health, o.mime_type as MimeType, o.created_at as ModTime, o.etag as ETag"). Model(&dbObject{}). Table("objects o"). Joins("INNER JOIN buckets b ON o.db_bucket_id = b.id"). diff --git a/stores/metadata_test.go b/stores/metadata_test.go index 47d004957..55bf93573 100644 --- a/stores/metadata_test.go +++ b/stores/metadata_test.go @@ -3492,6 +3492,13 @@ func TestListObjects(t *testing.T) { {"/foo", "size", "ASC", "", []api.ObjectMetadata{{Name: "/foo/bar", Size: 1, Health: 1}, {Name: "/foo/bat", Size: 2, Health: 1}, {Name: "/foo/baz/quux", Size: 3, Health: .75}, {Name: "/foo/baz/quuz", Size: 4, Health: .5}}}, {"/foo", "size", "DESC", "", []api.ObjectMetadata{{Name: "/foo/baz/quuz", Size: 4, Health: .5}, {Name: "/foo/baz/quux", Size: 3, Health: .75}, {Name: "/foo/bat", Size: 2, Health: 1}, {Name: "/foo/bar", Size: 1, Health: 1}}}, } + // set common fields + for i := range tests { + for j := range tests[i].want { + tests[i].want[j].ETag = testETag + tests[i].want[j].MimeType = testMimeType + } + } for _, test := range tests { res, err := ss.ListObjects(ctx, api.DefaultBucketName, test.prefix, test.sortBy, test.sortDir, "", -1) if err != nil {