[drupal-devel] [bug] file_copy returns original (not final) filename on FILE_EXISTS_RENAME

ejort drupal-devel at drupal.org
Mon Jun 27 01:47:42 UTC 2005


Issue status update for http://drupal.org/node/24923

 Project:      Drupal
 Version:      cvs
 Component:    file system
-Category:     feature requests
+Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  cidenton
 Updated by:   ejort
-Status:       active
+Status:       patch
 Attachment:   http://drupal.org/files/issues/file.inc.update_filename.patch (623 bytes)

Is there anybody who has an opinion on this?  Personally I find it
counter-intuitive for the filepath to be updated but not the filename,
and I can't think of any uses where  the original filename is
preferable to the actual filename.  In any case the caller still has
access to the original filename if they care about it, what's returned
should reflect reality IMO.


I've been using this patch (against 4.6) so that the flexinode file
field is usable, as cidenton said it's a trivial fix, but without it
any file that is uploaded through the flexinode file field that must be
renamed cannot be downloaded (making this unusable in production). 
Because of this I'm changing this from a feature request to a bug
report.


Cheers,
Eric




ejort



Previous comments:
------------------------------------------------------------------------

June 14, 2005 - 02:22 : cidenton

The file_copy function in file.inc provides automatic file renaming in
case of name conflict, but doesn't put the final name in
$file->filename.  This makes it harder for modules to determine whether
they own a file presented to hook_file_download(); in particular,
flexinode modules will fail to determine that they own a file that got
renamed.  


If it is agreed that the final filename should be returned in
$file->filename, that behavior is easily imlemented by updating
$basename as well as $dest around line 261.  I will be happy to build
and test a patch for this.  If the current behavior is by design, I
will hack on my flexinode module fields instead.  What is the call?


Regards,
Claude







More information about the drupal-devel mailing list