Skip to content

Commit f1dd32d

Browse files
andrey-qlogicJesseLovelace
authored andcommitted
---
yaml --- r: 16371 b: refs/heads/autosynth-iot c: 4aa0737 h: refs/heads/master i: 16369: cd09493 16367: c2aaaa9
1 parent d2c4d80 commit f1dd32d

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
@@ -133,7 +133,7 @@ refs/heads/autosynth-datastore: 9acd400b484d6691a080c9152a331d88d24fefc1
133133
refs/heads/autosynth-dialogflow: d7477419376eac9b6dcc7dbcede581152527351d
134134
refs/heads/autosynth-errorreporting: 9891e73a56af7c097829ca7a521b0e862ba6af30
135135
refs/heads/autosynth-firestore: ddb29f8ee445a938fc40be8227dea87b3f508ab3
136-
refs/heads/autosynth-iot: 1ee33dce9c137938be0650f065717700d78f9bf6
136+
refs/heads/autosynth-iot: 4aa0737f6c32ffe4057a3f6a3b22fb9d3620e0eb
137137
refs/heads/autosynth-kms: dcc6e15d68759010c8735cc868135bd7e6c1cc5f
138138
refs/heads/autosynth-language: 8972866b016473559702424205ce5569de47b34d
139139
refs/heads/autosynth-os-login: daa910328b954bbe87068f684a3088ed910f1ddf

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