Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GCS NIO readAttributes returns CloudStorageObjectAttributes for directory like objects #3918

@tomcham

Description

@tomcham

Thanks for stopping by to let us know something could be better!

Please include as much information as possible:

Environment details

  • google-cloud-java version(s): google-cloud-nio:0.69.0-alpha

Steps to reproduce

  1. In the GCS UI within a bucket, press create folder button and create a folder called dir
  2. Upload a file within dir call this fileA

Code snippet

    FileSystem fs = ....
    Files.walkFileTree(fs.getPath("dir") new SimpleFileVisitor<Path>() {
      @Override
      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
        System.out.println(file);
        return FileVisitResult.CONTINUE;
      }

Any additional information below

The GCS UI creates a 0 byte object called dir/ This causes readAttributes to return https://github.com/googleapis/google-cloud-java/blob/v0.69.0/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java#L765, which prevents further traversal of objects within that directory.

Does it make sense to do a check like https://github.com/googleapis/google-cloud-java/blob/v0.69.0/google-cloud-clients/google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProvider.java#L756 usePseudoDirectories is enabled and it is a 0 byte object?

I saw this related merged PR https://github.com/googleapis/google-cloud-java/pull/3775/files by @jean-philippe-martin

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions