Imagecache allows me to run files through presets that are not in the files directory. For example:

files/imagecache/preset/misc/drupalicon.png

So the call:

if (file_exists($file_dir . '/' . $relative_path)) { 

fails.

Comments

mikeytown2’s picture

subscribe; another issue is _stage_file_proxy_fetch() doesn't get called in this code block

    // is this an imagecache request? if so, request only the root file and let imagecache handle resizing
    if (variable_get('stage_file_proxy_use_imagecache_root', TRUE) && strpos($relative_path, 'imagecache') === 0) {
      $relative_path = preg_replace('/imagecache\/.*\/(.*)/U', '$1', $relative_path);
      if (file_exists($file_dir . '/' . $relative_path)) {
        return; // imagecache can generate it without our help.
      }
    }

One more is with 'stage_file_proxy_hotlink' enabled it failed to generate the image locally from the root file. So it looks like the above logic needs some help.

c4rl’s picture

Status: Active » Needs review
StatusFileSize
new875 bytes

Indeed, imagecache_create_path() strips the file directory sometimes, so the file could exist in the files directory or elsewhere.

Attached patch checks for existence outside of files directory in addition to files directory.

greggles’s picture

Thanks for providing this patch and explaining it. With a 7.x port I'd commit it.

David_Rothstein’s picture

thedavidmeister’s picture

Issue summary: View changes

Unless I misunderstand the problem, I don't think there's a need for a d7 port as image style derivatives in d7 cannot be created outside the files directory. This is a d6 specific issue.

greggles’s picture

Status: Needs review » Fixed

Thanks for that feedback, thedavidmeister. Committed to 6.x-1.x http://drupalcode.org/project/stage_file_proxy.git/commit/e92c474

Thanks for the patch, c4rl!

Status: Fixed » Closed (fixed)

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

jcisio’s picture

Thanks. I was just going to submit a patch :-)

jcisio’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new844 bytes

The commit did not totally fix that issue and introduced a warning for files in the files directory. The attached patch should fix that.

This might also fix problem like #1545912: stage_file_proxy should check if the file already exists, even if it's not an imagecache in D6. The D7 code base is different, but now in D6 a have a lot of warning for existing files using the latest dev version.

jcisio’s picture

Status: Needs review » Closed (fixed)

Nope. Patch #9 makes no sense because $relative_path can only have "imagecache/" at the beginning. I think something in #2159705: Not checking files directory recursively before save disturbed my test.