Looking through the upload module looks like there is a potentially nasty race condition.

User A - Starts node 1
User A - Upload's file named 'readme.txt'
User A - Drupal displays the url as $baseurl/files/readme.txt
User A - Session redirects url to file stored in session
User B - Starts node 2
User B - Upload's file named 'readme.txt'
User B - Drupal displays the url as $baseurl/files/readme.txt
User B - Session redirects url to file stored in session
User B - Commits node 2. File saved with 'readme.txt' filename
User A - Commits node 1. All links and urls now point to the 'readme.txt' upload for node 2

Comments

dries’s picture

Priority: Critical » Normal

I'm lower the priority because there exist similar cases in the rest of Drupal.

urbanfalcon’s picture

It seems like the solution would be to prepend the images with the node ID, which would very much lessen the chance of this happening. This is what I have done for my own installation (with a few hacks in upload.module). Another positive is that you'll immediately know where images/uploads are being used when poking around in the /files directory.

harry slaughter’s picture

why not fix this and more by giving uploads a more private namespace?

the single upload dir is a significant drawback in the upload module IMHO.

i'm attempting to modify the module so that an admin can optionally choose to create unique dirs on a per user and node basis.

files would go in [files]/$userid/$nodeid/ instead of [files]/

but i'm having quite the time trying to do this. it definitely shouldn't be difficult thing to do, but the code is pretty difficult to follow because the upload destination directory is calculated multiple times (for the same info).

also see:
http://drupal.org/node/28769

m3avrck’s picture

Any updates with this issue?

m3avrck’s picture

Component: upload.module » base system

Dries said this was a global issue, updating the status. Haven't run into this myself but I see the possible problem. Can anyone confirm this?

What about a patch?

magico’s picture

Any news about this? I think there were introduced several new features to avoid race conditions.

Leeteq’s picture

FYI/alternative: http://drupal.org/project/attachment
("Thread safe - This module prevents users from accidentally seeing other users uploads")

AmirTheSeventh’s picture

Version: x.y.z » 4.7.4

The idea of using one directory for all files is only good for small sites with few users.
Just imagine: you got many users that create their own nodes, they edit the node with WYSISYG and want to add picture or flash to the node and/or attach several files. current drupal's file system is not going to be effective. I looked at modules called, attachment and filemanager. they are not well maintained, are not (well) documented and are not going to be ported to Drupal 5.x.

If we want to have/create a good file/attachment management system, we need to go through 2 steps, First creation and second creation. First creation also called mental creation is to creating ideal mental image of what we want, then with having the first creation we start the second creation also called physical creation.
let's work together on the mental creation, please add the features you need and implementation path you suggest and your reasoning

Features :
-Supports limitations by each roles.
-can deal with same filename.ext added by same user/different user
-Supports history version of files
-have check in/out for each file
-Don't make it complicated for smaller sites
-Support other languages characters
-size limitation by node/user
-extension limitation by node/user
-ability to deal with space in the filename
-files can be saved somewhere other than Drupal directory

Implementation path:
- use a path like flies/node/[node#] for storing files related to a node*
*because everything is a node in Drupal, I think its better to use such a path, node# directory with all it's files will be deleted if someone delete the node
- use a path like flies/user/[user#] for storing files related to a user, user# directory with all it's files will be deleted if someone delete the user
- use database tables to save file attribute (hidden, read only, checked out, etc) and file history (who modified, modification time stamp, etc)

zro’s picture

Version: 4.7.4 » 5.x-dev
Component: base system » upload.module

seems to be a huge issue.
any word on this?

Anonymous’s picture

Version: 5.x-dev » 6.x-dev

I just love old bug reports.

The suggestion at #3 is what I would prefer to see with the site setup for the files directory allowing for this. So I would state files/[#userid]/[#nodeid] or files/[#nodeid] or files/[#userid] in the setup and upload module would be smart enough to create the directory structure if it was missing.

So who's going to be the first to create a patch?

Tom-182’s picture

Still no solution for this issue?
I've tried using uploadpath module http://drupal.org/project/uploadpath but it seemed that it still have bugs http://drupal.org/node/133570

I've ask this kind of question in the forum but still got no answer after 2 days.
http://drupal.org/node/133122

xqus’s picture

As far as I can see this problem does not exists in the current CVS version.

chx’s picture

Status: Active » Fixed

Then its fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)
arhak’s picture

subscribing