Skip to content

Commit fc4e250

Browse files
maxtomassichingor13
authored andcommitted
---
yaml --- r: 28519 b: refs/heads/master c: 4748868 h: refs/heads/master i: 28517: 550b927 28515: d74b873 28511: 6fe58a7
1 parent 9b75a3a commit fc4e250

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

  • trunk/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a58dbb7e2220104c06839d986e1a352acb44e668
2+
refs/heads/master: 4748868df47c09fb13a244750e24612a87e20871
33
refs/heads/gh-pages: 9b91392095cbb68bba1a32efe7d8caeac44467d9
44
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
55
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

trunk/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public Tuple<String, Iterable<StorageObject>> list(String bucket, Map<Option, ?>
163163
if (processedAsFolder(so, delimiter, prefix, folders)) {
164164
continue;
165165
}
166+
so.setSize(size(so));
166167
values.add(so);
167168
}
168169
values.addAll(folders.values());
@@ -205,9 +206,7 @@ public StorageObject get(StorageObject object, Map<Option, ?> options) throws St
205206
String key = fullname(object);
206207
if (metadata.containsKey(key)) {
207208
StorageObject ret = metadata.get(key);
208-
if (contents.containsKey(key)) {
209-
ret.setSize(BigInteger.valueOf(contents.get(key).length));
210-
}
209+
ret.setSize(size(ret));
211210
ret.setId(key);
212211

213212
return ret;
@@ -474,6 +473,16 @@ private String fullname(StorageObject so) {
474473
return (so.getBucket() + "/" + so.getName());
475474
}
476475

476+
private BigInteger size(StorageObject so) {
477+
String key = fullname(so);
478+
479+
if (contents.containsKey(key)) {
480+
return BigInteger.valueOf(contents.get(key).length);
481+
}
482+
483+
return null;
484+
}
485+
477486
private void potentiallyThrow(Map<Option, ?> options) throws UnsupportedOperationException {
478487
if (throwIfOption && !options.isEmpty()) {
479488
throw new UnsupportedOperationException();
@@ -525,6 +534,7 @@ private static boolean processedAsFolder(
525534
fakeFolder.setBucket(so.getBucket());
526535
fakeFolder.setGeneration(so.getGeneration());
527536
fakeFolder.set("isDirectory", true);
537+
fakeFolder.setSize(BigInteger.ZERO);
528538
folders.put(folderName, fakeFolder);
529539
return true;
530540
}

0 commit comments

Comments
 (0)