Hello

I investigated a lot of time today for this tiny bug report. Uploading FLV videos with useroot=0 is not working. It results in a rename() error and does not publish the flv.
===
rename(/home/sites/test/web/files/155_bla.flv,/home/sites/test/web/) [function.rename]: Not a directory in /home/sites/test/web/sites/all/modules/flashvideo/flashvideo.module in Zeile 1169.
===

The source problem is at flashvideo.module @1143:
$newfile->filepath = $useroot ? $params['output_dir'] . $newfile->filename : file_create_path($params['output_dir'] . $newfile->filename);

file_create_path will fail here as filename is not containing the right path (at least when uploading FLV in our tests.
Something like this works for my tested situations:
newfile->filepath = $useroot ? $params['output_dir'] . $newfile->filename : file_directory_path().'/'. $params['output_dir'] . $newfile->filename;
$output_path = getcwd() . '/' . $newfile->filepath;

I don't see the full reason yet but when i remove the file_create_path and add the files directory it all works perfectly.
What's wrong with it?
I'm sometimes very confused about path variable names and complexity. Possibly one should declare the path domains within the documentation - or much better bind them to a common declaration.

Any inputs about this issue? After this tweak everything looks fine again..

Thanks!

Comments

travist’s picture

The problem is with the private file system. What you mentioned above would break private file systems. I will look into your problem and see if I can find a better solution.

Thanks,

Travis.

miro_dietiker’s picture

Thanks Travis.

What i was unable to understand was, why the following code part returned some empty string (i believe FALSE).
file_create_path($params['output_dir'] . $newfile->filename)

Internally file_create_path uses file_check_location which uses realpath. Thus referencing implicitly to cwd (?). Something looks here very odd.

While i was testing, it still returned empty when i prepended the following, but possibly there was something totally wrong.
file_directory_path().'/'
(Edit: I've tested again and path validation still failed to empty. I was testing in public file mode.)

I didn't understand what this all has to do with the private files as i see no code relating to {files} entries and such things..

Any idea?

thisisnotrealpeople’s picture

I had the same issue. Here's what I did to fix it:

Replace (line 971):
// Get the CWD filepath.
$filepath = getcwd() .'/'. $file->filepath;

With:
// Get the CWD filepath.
$filepath = $file->filepath;

Replace (line 1031):
// Get the output path.
$output_path = getcwd() .'/'. $newfile->filepath;

With:
// Get the output path.
$output_path = $newfile->filepath;

This issue was encountered due to a private file system. This change will break your stuff if your file system is public.

Oh and I'm using Drupal 6.14.

attheshow’s picture

Category: bug » feature
Status: Active » Needs work

Until we have a fix that works for both private and public, I think we need to give priority to public filesystems in the code.