It appears that filefield is saving files directly to the path chosen for the file field, immediately upon the user hitting "upload" and before they've saved the node. I'd assumed that it would use the temporary directory from "admin/settings/file-system" for uploads, and then move files to the path chosen in the field settings only after the node was saved. This does not appear to be the case.
I understand that files are considered temporary in the database until marked permanent, and that orphaned temp files are cleaned up periodically, however, it would be much better if files not yet marked permanent were stored in the temp folder and only then moved to the permanent folder at that time.
Here's what's happening to me:
A user selects a file, hits upload, sees the message saying it was uploaded successfully and then doesn't hit the save/submit button on the node.
This results in a file being uploaded to the _final_ files directory I set up for that filefield.
Here's where the problem comes in - the directory in question o is a "watch" folder that our video transcoding service provider checks every five minutes for new files to transcode.
So, user uploads a huge file, doesn't hit save, no database record is created for the file, our transcoder sucks up the orphan file and bills us, and we end up with a video file that we have no node created for.
Or, user uploads file, hasn't _yet_ hit save, realizes they didn't want to upload _that_ file, so they pick another one, but in the meantime, the first file has already been sucked into the transcoding system.
Or, and here's my favorite one - the user is uploading an enormous file on a slow connection, and the transcoding watch agent sees the file before it's even finished uploading, tries to ingest it, and gets a mangled file.
Yikes!
Please, please, please, make it so that the drupal temporary directory (or a filefield-specific temp directory) is used for uploads!
Coyote
Comments
Comment #1
Coyote commentedBTW: Apologies if what I wrote sounded snarky - after all these years, I still forget that email doesn't carry the sound of a voice.
Comment #2
ShawnClark commentedWhile tracing some of #292151: Files are not deleted when replaced issue I have noticed this myself. It is something that caught me off guard as the previous versions of ImageField would use the temp directory and then move the file when the node was actually saved.
The problem is within filefield_widget.inc on line 135 where it is creating the $dest variable. That variable is then used on line 142 when saving the uploaded file. Here is the relevant code:
I haven't gotten any further in my poking around yet to see where the module sets the status of the file within the files table to be permanent but guessing that would be the best place to have it move a file from a temporary location to a permanent location.
Comment #3
dopry commentedThis is the default behavior for D6 and later in general to simplify preview handling. You should check the database... not the folder for your transcoding service...