filesize(), filectime() and filetype() functions fail on certain folders.

protected function createServerFileList($node, $relative_path) {
    // ...
    $files = file_scan_directory($directory, '/.*/', ['recurse' => false]);
    debug($files);
    // outputs all files in $directory

   foreach ($files as $key => $file) {
     $file->size = filesize($file->uri);
     $file->type = filetype($file->uri);
     $file->timestamp = filectime($file->uri);
       return $files;
  }

directory contains directories and files. For the files, the stat functions performs well. But for most (not all) of the directories the stat() functions will fail:

  User warning: stat(): No such file or directory in Twistor\FlysystemStreamWrapper->triggerError() (line 887 of
vendor\twistor\flysystem-stream-wrapper\src\FlysystemStreamWrapper.php).
Warning: filesize(): stat failed for s3://documenten in Drupal\filebrowser\ServerFileList->createServerFileList() (line 87 of modules\filebrowser\src\ServerFileList.php).
User warning: stat(): No such file or directory in Twistor\FlysystemStreamWrapper->triggerError() (line 887 of vendor\twistor\flysystem-stream-wrapper\src\FlysystemStreamWrapper.php).
Warning: filetype(): Lstat failed for s3://documenten in Drupal\filebrowser\ServerFileList->createServerFileList() (line 88 of modules\filebrowser\src\ServerFileList.php).
User warning: stat(): No such file or directory in Twistor\FlysystemStreamWrapper->triggerError() (line 887 of vendor\twistor\flysystem-stream-wrapper\src\FlysystemStreamWrapper.php).
Warning: filectime(): stat failed for s3://documenten in Drupal\filebrowser\ServerFileList->createServerFileList() (line 90 of modules\filebrowser\src\ServerFileList.php).
$schemes['s3'] = [
  'driver' => 's3',
  'config' => [
    'key'    => key,
    'secret' => secret,
    'region' => 'eu-west-1',
    'bucket' => 'nftr',

    #Optional configuration settings.
    #'options' => [
    #  'ACL' => 'public-read',
    #  'StorageClass' => 'REDUCED_REDUNDANCY',
    #],

  #'protocol' => 'https',
  #'prefix' => 'prefix',
  #'cname' => 'static.example.com',   // A cname that resolves to your bucket. Used for URL generation.
  ],

  'cache' => TRUE, // Creates a metadata cache to speed up lookups.
];
CommentFileSizeAuthor
#5 flysystem_s3-2808579-3.patch1.13 KBtwistor

Comments

clivesj created an issue. See original summary.

twistor’s picture

Project: Flysystem » Flysystem - S3
Category: Support request » Bug report
twistor’s picture

Status: Active » Needs review

Can you make sure league/flysystem-aws-s3-v3 is up-to-date. Should be at version 1.0.11.

Then, try this patch.

clivesj’s picture

λ composer show
league/flysystem-aws-s3-v3           1.0.11       Flysystem adapter for the AWS S3 SDK v3.x

Can you supply the link to the patch?

twistor’s picture

StatusFileSize
new1.13 KB

oops, I forgot the patch.

twistor’s picture

Is the problem that some of these directories were create by Drupal, and that some were not? If so, then this patch should fix it.

clivesj’s picture

I was trying to find out if there was any consistencies between the failing directories. But couldn't find any.
As a matter of fact I can not reproduce the errors on my today's trials. Even the ones failing before. I have been switching between PHP versions. I am wondering whether caching is involved.
Any way I would like to propose to put the the issue status to *postponed - maintainer needs more info* until I can come back with more specific feedback.

twistor’s picture

Another thing to check would be the S3 permissions.

deviantintegral’s picture

Sounds like we can close this, unless we've got a reproduction for it?

clivesj’s picture

Status: Needs review » Closed (cannot reproduce)

Yes, thank you.