Skip to content

Commit dec9296

Browse files
committed
---
yaml --- r: 2359 b: refs/heads/update-datastore c: ba4bfa6 h: refs/heads/master i: 2357: 2aaa4e7 2355: 5a4bc6c 2351: 4129e6d
1 parent 4e8f97a commit dec9296

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
66
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
8-
refs/heads/update-datastore: f11c05a4846d598984fee5c132493d962fdf92e0
8+
refs/heads/update-datastore: ba4bfa6017b39800abfda831ee071664802e6186
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Bucket.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static com.google.common.base.Preconditions.checkNotNull;
21+
import static com.google.gcloud.storage.Bucket.BucketSourceOption.toGetOptions;
22+
import static com.google.gcloud.storage.Bucket.BucketSourceOption.toSourceOptions;
2123

2224
import com.google.common.base.Function;
2325
import com.google.common.base.MoreObjects;
@@ -35,6 +37,7 @@
3537
import java.io.ObjectInputStream;
3638
import java.io.Serializable;
3739
import java.util.ArrayList;
40+
import java.util.Arrays;
3841
import java.util.Collections;
3942
import java.util.Iterator;
4043
import java.util.List;
@@ -218,8 +221,11 @@ public BucketInfo info() {
218221
* @return true if this bucket exists, false otherwise
219222
* @throws StorageException upon failure
220223
*/
221-
public boolean exists() {
222-
return storage.get(info.name()) != null;
224+
public boolean exists(BucketSourceOption... options) {
225+
int length = options.length;
226+
Storage.BucketGetOption[] getOptions = Arrays.copyOf(toGetOptions(info, options), length + 1);
227+
getOptions[length] = Storage.BucketGetOption.fields();
228+
return storage.get(info.name(), getOptions) != null;
223229
}
224230

225231
/**
@@ -230,8 +236,7 @@ public boolean exists() {
230236
* @throws StorageException upon failure
231237
*/
232238
public Bucket reload(BucketSourceOption... options) {
233-
return new Bucket(storage, storage.get(info.name(),
234-
BucketSourceOption.toGetOptions(info, options)));
239+
return new Bucket(storage, storage.get(info.name(), toGetOptions(info, options)));
235240
}
236241

237242
/**
@@ -259,7 +264,7 @@ public Bucket update(BucketInfo bucketInfo, BucketTargetOption... options) {
259264
* @throws StorageException upon failure
260265
*/
261266
public boolean delete(BucketSourceOption... options) {
262-
return storage.delete(info.name(), BucketSourceOption.toSourceOptions(info, options));
267+
return storage.delete(info.name(), toSourceOptions(info, options));
263268
}
264269

265270
/**

branches/update-datastore/gcloud-java-storage/src/test/java/com/google/gcloud/storage/BucketTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,16 @@ public void testInfo() throws Exception {
7575

7676
@Test
7777
public void testExists_True() throws Exception {
78-
expect(storage.get(BUCKET_INFO.name())).andReturn(BUCKET_INFO);
78+
Storage.BucketGetOption[] expectedOptions = {Storage.BucketGetOption.fields()};
79+
expect(storage.get(BUCKET_INFO.name(), expectedOptions)).andReturn(BUCKET_INFO);
7980
replay(storage);
8081
assertTrue(bucket.exists());
8182
}
8283

8384
@Test
8485
public void testExists_False() throws Exception {
85-
expect(storage.get(BUCKET_INFO.name())).andReturn(null);
86+
Storage.BucketGetOption[] expectedOptions = {Storage.BucketGetOption.fields()};
87+
expect(storage.get(BUCKET_INFO.name(), expectedOptions)).andReturn(null);
8688
replay(storage);
8789
assertFalse(bucket.exists());
8890
}

0 commit comments

Comments
 (0)