Skip to content

Commit 5339e78

Browse files
jean-philippe-martinneozwu
authored andcommitted
---
yaml --- r: 8129 b: refs/heads/tswast-patch-1 c: 466a8d4 h: refs/heads/master i: 8127: 4715f43
1 parent 2bcb666 commit 5339e78

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 7c20c6f0663147ed667d782c1e37551d80fc74e7
60+
refs/heads/tswast-patch-1: 466a8d4f70aab42596007f4a3fb07b791f363509
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ private static class LazyPathIterator extends AbstractIterator<Path> {
9797
private final Iterator<Blob> blobIterator;
9898
private final Filter<? super Path> filter;
9999
private final CloudStorageFileSystem fileSystem;
100+
private final String prefix;
100101

101-
LazyPathIterator(CloudStorageFileSystem fileSystem, Iterator<Blob> blobIterator,
102+
LazyPathIterator(CloudStorageFileSystem fileSystem,
103+
String prefix,
104+
Iterator<Blob> blobIterator,
102105
Filter<? super Path> filter) {
106+
this.prefix = prefix;
103107
this.blobIterator = blobIterator;
104108
this.filter = filter;
105109
this.fileSystem = fileSystem;
@@ -110,6 +114,10 @@ protected Path computeNext() {
110114
while (blobIterator.hasNext()) {
111115
Path path = fileSystem.getPath(blobIterator.next().getName());
112116
try {
117+
if (path.toString().equals(prefix)) {
118+
// do not return ourselves, because that confuses recursive descents.
119+
continue;
120+
}
113121
if (filter.accept(path)) {
114122
return path;
115123
}
@@ -617,14 +625,14 @@ public DirectoryStream<Path> newDirectoryStream(Path dir, final Filter<? super P
617625
final CloudStoragePath cloudPath = CloudStorageUtil.checkPath(dir);
618626
checkNotNull(filter);
619627
initStorage();
620-
String prefix = cloudPath.toRealPath().toString();
628+
final String prefix = cloudPath.toRealPath().toString();
621629
final Iterator<Blob> blobIterator = storage.list(cloudPath.bucket(),
622630
Storage.BlobListOption.prefix(prefix), Storage.BlobListOption.currentDirectory(),
623631
Storage.BlobListOption.fields()).iterateAll().iterator();
624632
return new DirectoryStream<Path>() {
625633
@Override
626634
public Iterator<Path> iterator() {
627-
return new LazyPathIterator(cloudPath.getFileSystem(), blobIterator, filter);
635+
return new LazyPathIterator(cloudPath.getFileSystem(), prefix, blobIterator, filter);
628636
}
629637

630638
@Override

0 commit comments

Comments
 (0)