Simultaneous downloads may fail

Have a good idea ? Want to suggest something ? Have a couple of lines of code to back it up ?
Post it here !

Simultaneous downloads may fail

Postby wolf on 05-09-2007 07:54

I installed your updated download.php yesterday to enable non-standard character files to be downloaded. This went fine, but unfortunately I also peeked at the code, and discovered something.

Imagine that two users are downloading the same album simultaneously. According to the script, the MP3 files are copied to the /tmp directory, tared, and then deleted.

This means that as soon as the files are combined for one user, they're deleted from the /tmp folder, possibly before the other user's archive has been finished, causing the second user to lose files.

It's not a problem that can be expected to occur often, but it's easy to fix: simply create a folder in the /tmp directory for each user, and create the archive for download in the user's folder.

Of course, if the same user downloads the same files twice, you'll face the same problem, but possibly with a lower probability. This can also be fixed easily by creating a temporary folder for each download session.
wolf
AmpJuke user
AmpJuke user
 
Posts: 35
Joined: 14-08-2007 22:06
Location: Aalborg, Denmark

Postby Michael on 05-09-2007 12:54

Hi wolf,

You're right: It's not something that can be expected to happen a lot...
I have another suggestion that happen to work immediately :)

Comment out this line (around 130) in download.php:
Code: Select all
   exec($rm_cmd);

...so it says:
Code: Select all
//   exec($rm_cmd);

(or delete the line completely)

Result: downloaded files will be in ./tmp for 24 hours, and subsequently cleared (see bottom of make_header.php).

However, your suggestion is taken into account as an improvement in a later version (read: not 0.6.4).
Thanks again for the suggestion.

//Michael.
User avatar
Michael
Site Admin
Site Admin
 
Posts: 449
Joined: 03-07-2007 13:46
Location: Denmark


Return to Requests / suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron