Skip to content

Commit c46245d

Browse files
maxtomassichingor13
authored andcommitted
---
yaml --- r: 30591 b: refs/heads/autosynth-automl c: 4748868 h: refs/heads/master i: 30589: 026e8be 30587: 3e41427 30583: 6f271ae 30575: 954ef92 30559: 2961772 30527: 2aa8d2f 30463: 61d5885
1 parent e95bb15 commit c46245d

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

  • branches/autosynth-automl/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
@@ -121,7 +121,7 @@ refs/heads/spanner: b01127f885b4611bf1852abb0ce481eeb7fcc131
121121
refs/tags/v0.68.0: 9cc799fcf68c82ab431d425fefa58ef615ce8e5b
122122
refs/tags/v0.69.0: 78f67a29e8b9c46ba01de566a2eae0fd1c03edea
123123
refs/heads/autosynth-asset: bdb45634a0fe8f7a510692b56b31f5312e25f453
124-
refs/heads/autosynth-automl: a58dbb7e2220104c06839d986e1a352acb44e668
124+
refs/heads/autosynth-automl: 4748868df47c09fb13a244750e24612a87e20871
125125
refs/heads/autosynth-bigquerydatatransfer: d88aa5aae5fd9d3c6d75bbab1a05162c6d4d948f
126126
refs/heads/autosynth-bigquerystorage: d2c53da3b012e38c662e4df0738042435f19365f
127127
refs/heads/autosynth-bigtable: 9e5429f45cf9face9fed585d0233534993e36b58

branches/autosynth-automl/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)