Ok. Let's see the first issue described on my previous track #921414: Issues when downloading; and this concerns only the dev version timestamped 2010/09/19.

  1. The folder's rights -> Download Manager is set to "Direct Download":
    When you click on any file, (e.g. http://example.com/filebrowser/download/22 and the file is "Text.txt), the url is redirected to http://example.com/.txt and you get an 404 Error
  2. The folder's rights -> Download Manager is set to "Private Download":
    The same url is correct, and pointed to the right file, but it's displayed and not forced to download.

There's the same issue when:

  • Drupal's File System is configure to Public or private
  • PHP version 5.2.x or 5.3.x
CommentFileSizeAuthor
#8 filebrowser-truncate-924812-1.diff381 bytesNicolas Georget

Comments

Nicolas Georget’s picture

i checked a while your code and i think i found the error: It's into your function filebrowser_filebrowser_download_manager_process() line 888:

if (strpos($web_root, $file) == 0) {
  ...
}

Should be:

if (strpos($web_root, $file) === 0) {

Or better you should write: if (strpos($web_root, $file) === false) {...} to be sure of the condition value that returned.

Can you confirm before to close the issue ?

clivesj’s picture

Same problem, Solved.
Using the sept 19th dev version, I had this problem.

The download location filesbrowser/download/125 was not pointing to the proper location.
The files/folder part of the URL was truncated and the file was not found.
After changin line 888 as you suggested it is working as a charm now.
Thanks

Nicolas Georget’s picture

And i should learn php ;-)
{...} === 0 is not equivalent to {...} === false

Anyway, i let Yoran fix and close this track

clivesj’s picture

I still have problems with this as the URL is truncated and therefore not ointing to the proper location.

The code from line 888:

$web_root; /home/peter/test/drupal
$file: site/default/files/musicdocs/classical/song1.pdf

strpos return FALSE and truncates $target to ; cdocs/classical/song1.pdf ($file minus length of $webroot).

Browser goes to http://www.example.com/cdocs/classical/song1.pdf and does not find the file.

If I change to code to
if (!strpos($web_root, $file) == 0) // !

the browser goes to

http;//www.example.com/site/default/files/musicdocs/classical/song1.pdf and finds the file

Nicolas Georget’s picture

Sorry, i don't get it:

$web_root = "/home/peter/test/drupal";
$file = "site/default/files/musicdocs/classical/song1.pdf";
$pos = strpos($web_root, $file);
echo $pos ? "true" : "false";

And it returns false as expected.

So if strpos return FALSE, how PHP can truncates $target ?!

if (strpos($web_root, $file) === 0) { // if is true so it truncates
  $target = substr($file, strlen($web_root));
}
else { // is false so it doesn't truncate
  $target = $file;
}
clivesj’s picture

Hello Nicolas,
Well this is very stupid of me:

My code was:

if (strpos($web_root, $file) == 0) {

I changed == into === before as stated in your post #1, but because I re-installed the module I lost that manual change.
I re-corrected the double equation into triples, and now everything works fine again.
Any chance that you can roll an updated -dev version?
Thanks for the nice module and your time.

Nicolas Georget’s picture

Any chance that you can roll an updated -dev version?

I would like but i don't have the access to the filebrowser's SVN. Only Yoran is the maintainer of this module. And he "disappears from the planet drupal" since 2 months now.
Actually, i made many patches (#924856: File as Attachment or Inline and/or #924988: Zip Archive created and download it) to resolve some bugs and i see many tracks could be duplicated #842682: File downloads inaccessible after upgrading, various error messages
We definitively need a new dev version.

Nicolas Georget’s picture

StatusFileSize
new381 bytes

Submitting a patch (Yoran, where are you ?!??)

clivesj’s picture

Status: Active » Reviewed & tested by the community
Yoran’s picture

Fixed in dev. Thanks Nicolas.

Once again, If you have any blocking issue, never hesitate to shake me by email !! This bug tracker is ..., hum, let's say no easy to follow :)

Yoran’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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