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

Fix updateMetadata in gcloud, release 0.8.18 #188

Merged
merged 2 commits into from
Nov 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/gcloud/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.18
- Fix bug in `Bucket.updateMetadata` such that `acl: null` is allowed.
Since, this is the only valid value for buckets with uniform access policies.

## 0.8.17
- Fix bug in `ObjectMetadata.replace` where `contentEncoding` overwrote
`contentDisposition` and `contentLanguage`.
Expand Down
8 changes: 4 additions & 4 deletions pkgs/gcloud/lib/src/storage_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ class _BucketImpl implements Bucket {
// TODO: support other ObjectMetadata implementations?
var md = metadata as _ObjectMetadata;
var object = md._object;
if (md._object.acl == null && _defaultObjectAcl == null) {
throw ArgumentError('ACL is required for update');
}
if (md.contentType == null) {
throw ArgumentError('Content-Type is required for update');
}
md._object.acl ??= _defaultObjectAcl!._toObjectAccessControlList();
// If no ACL is passed use the default (if any).
if (object.acl == null && _defaultObjectAcl != null) {
object.acl = _defaultObjectAcl!._toObjectAccessControlList();
}
return _api.objects.update(object, bucketName, objectName);
}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/gcloud/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: gcloud
version: 0.8.17
version: 0.8.18
description: >-
High level idiomatic Dart API for Google Cloud Storage, Pub-Sub and Datastore.
repository: https://github.com/dart-lang/labs/tree/main/pkgs/gcloud
Expand Down
26 changes: 26 additions & 0 deletions pkgs/gcloud/test/storage/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,5 +341,31 @@ void main() {
], (Function f) => f().then(expectAsync1((_) {})));
});
});

test('update-metadata', () {
return withTestBucket((Bucket bucket) async {
await bucket.writeBytes(
'test-m',
metadata: ObjectMetadata(
contentType: 'application/test-1',
),
[1, 2, 3],
);

final info = await bucket.info('test-m');
expect(info.metadata.contentType, 'application/test-1');

await bucket.updateMetadata(
'test-m',
ObjectMetadata(
contentType: 'application/test-2',
));

final info2 = await bucket.info('test-m');
expect(info2.metadata.contentType, 'application/test-2');

await bucket.delete('test-m');
});
});
});
}