google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

[Storage] scandir() truncates names in "root directory"

Open ava12 opened this issue 6 years ago • 3 comments

When scandir() is used with stream wrapper to list «top-level» objects (with no slashes in their names) listed names are truncated (the first byte of each name is missing).

Environment details

  • Package name and version: Google Cloud Storage, 1.21.0

Steps to reproduce

  1. Register stream wrapper.
  2. Create some objects with names containing no slashes.
  3. Call scandir() passing bucket name with no object name prefix.

Code example

$storage = new Google\Cloud\Storage\StorageClient();
$storage->registerStreamWrapper();
file_put_contents('gs://my-bucket/foo', 'hi ');
file_put_contents('gs://my-bucket/bar', 'all');
$names = scandir('gs://my-bucket'); // expected ['bar', 'foo']
var_dump($names); // got ['ar', 'oo']

ava12 avatar Jun 03 '20 22:06 ava12

@ava12 nice find. Is this something you can address along with the other stream wrapper work you've been doing?

jdpedrie avatar Jun 04 '20 12:06 jdpedrie

Well, I can add a commit to PR #3108, but I was thinking about a separate PR, which could be reviewed and approved quicker.

ava12 avatar Jun 04 '20 13:06 ava12

I agree, separate PR would be best. I just meant since you're already working on it and it's probably fresh in your mind.

jdpedrie avatar Jun 04 '20 13:06 jdpedrie