Skip to content

Commit 195120d

Browse files
andrey-qlogicJesseLovelace
authored andcommitted
---
yaml --- r: 13133 b: refs/heads/autosynth-spanner c: 4aa0737 h: refs/heads/master i: 13131: 9c52868
1 parent d02efa4 commit 195120d

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ refs/heads/autosynth-os-login: daa910328b954bbe87068f684a3088ed910f1ddf
140140
refs/heads/autosynth-redis: 4c68cb0fbc599124e717ab3f24bd8a8a5d085ca9
141141
refs/heads/autosynth-scheduler: 2f0fe714a8541dc72f88b45bddd8748e5f21cf29
142142
refs/heads/autosynth-securitycenter: 8e95447ccb176c3648880ee0cb926cd1f4065156
143-
refs/heads/autosynth-spanner: 1ee33dce9c137938be0650f065717700d78f9bf6
143+
refs/heads/autosynth-spanner: 4aa0737f6c32ffe4057a3f6a3b22fb9d3620e0eb
144144
refs/heads/autosynth-speech: 631df42a628621fe42eb4974c9eb725b2fe8e473
145145
refs/heads/autosynth-tasks: afc9f4da54964dea5e7f3a9b164db282fc35db5c
146146
refs/heads/autosynth-texttospeech: a447278ab2ec3975aab3b641549c6780eac0a07a

branches/autosynth-spanner/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,12 @@ public <A extends BasicFileAttributes> A readAttributes(
768768
}
769769
CloudStorageObjectAttributes ret;
770770
ret = new CloudStorageObjectAttributes(blobInfo);
771+
// if size is 0 it could be a folder
772+
if (ret.size() == 0 && cloudPath.seemsLikeADirectoryAndUsePseudoDirectories(storage)) {
773+
@SuppressWarnings("unchecked")
774+
A result = (A) new CloudStoragePseudoDirectoryAttributes(cloudPath);
775+
return result;
776+
}
771777
@SuppressWarnings("unchecked")
772778
A result = (A) ret;
773779
return result;

branches/autosynth-spanner/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileAttributesTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
public class CloudStorageFileAttributesTest {
3939

4040
private static final byte[] HAPPY = "(✿◕ ‿◕ )ノ".getBytes(UTF_8);
41+
private static final byte[] EMPTY = "".getBytes(UTF_8);
4142

4243
private Path path;
4344
private Path dir;
@@ -104,6 +105,14 @@ public void testIsDirectory() throws IOException {
104105
assertThat(Files.readAttributes(dir, CloudStorageFileAttributes.class).isDirectory()).isTrue();
105106
}
106107

108+
@Test
109+
public void testIsPseudoDirectory() throws IOException {
110+
Files.write(path, EMPTY);
111+
assertThat(Files.readAttributes(path, CloudStorageFileAttributes.class).isDirectory())
112+
.isFalse();
113+
assertThat(Files.readAttributes(dir, CloudStorageFileAttributes.class).isDirectory()).isTrue();
114+
}
115+
107116
@Test
108117
public void testIsRegularFile() throws IOException {
109118
Files.write(path, HAPPY);

0 commit comments

Comments
 (0)