With the latest dev of this module and latest stable of s3fs I get 500 errors for every page when enabling this module.

I get warnings and errors like:
Rename 2 failed. Current: public://advagg_file_DHdigz Target: public://advagg_css/advagg_file_DHdigz
and
File public://advagg_file_by1zyP could not be copied because it does not exist.
and
Warning: touch(): S3fsStreamWrapper::stream_metadata is not implemented! in advagg_save_data() (line 1307 of /sites/all/modules/contrib/advagg/advagg.missing.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dobe created an issue. See original summary.

jimmyko’s picture

jimmyko’s picture

I can confirm this bug as I reported in #2721469-43: AdvAgg & s3fs: rename and temp dir issues..

For the missing implementation of stream_metadata(), it is another bug from s3fs. Please see #2826372: AdvAgg - S3fsStreamWrapper::stream_metadata is not implemented.

jimmyko’s picture

According to my understanding, it seems the temporary file was created at temporary directory but not the location specify at $dir.

$temporary_file = @drupal_tempnam($dir, 'advagg_file_');

In my installation, `$dir` stored value `public://advagg_js/` but the temp files is created at '/tmp/' but not in S3 bucket.

When it go through `advagg_rename()`, the $source is always empty and its real path can never be found.

function advagg_rename($source, $destination) {
  $real_source = drupal_realpath($source);
  $real_source = $real_source ? $real_source : $source;
  $real_destination = drupal_realpath($destination);
  $real_destination = $real_destination ? $real_destination : $destination;

  if (!@rename($real_source, $real_destination)) {
    if (!file_unmanaged_move($source, $destination)) {
      return FALSE;
    }
  }

  return $destination;
}
jimmyko’s picture

Priority: Normal » Major

I move its priority to major since s3fs is wisely used in large-scale site.

mikeytown2’s picture

So first step is to not use touch, correct?

mikeytown2’s picture

Second step is to get rid of all the workarounds for the limitations of drupal_tempnam and just implement my own version as it shouldn't cause as many issues.

  • mikeytown2 committed e75bc20 on 7.x-2.x
    Issue #2843510 by mikeytown2: AdvAgg and s3fs fail
    
mikeytown2’s picture

Status: Needs review » Active
mikeytown2’s picture

I'll need feedback on if this change works. Thinking this will do the trick.

  • mikeytown2 committed 59d1bc2 on 7.x-2.x
    Issue #2843510 by mikeytown2: AdvAgg and s3fs fail
    
mikeytown2’s picture

Status: Needs review » Fixed

Should be fixed.

jimmyko’s picture

I think the last patch is going to the right track. I would like to remove the tedious conditions by replacing a custom file touch function too. But I didn't because I can't fully understand those long code B).

I will test it today. Thanks again.

jimmyko’s picture

I would like to say it works perfectly! Thanks @mikeytown2

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.