Logic sought

From: Date: Wed, 09 Jul 2008 23:45:43 +0000
Subject: Logic sought
Groups: php.general 
Request: Send a blank email to php-general+get-276546@lists.php.net to get a copy of this message
Hi gang: Here's the logic problem. First the site: http://php1.net/b/zip-files/ Now, the site works well enough. The user selects what they want, clicks Submit, the order is assembled in zip file and presented to the user for downloading. However, as it stands now, before the script assembles the test.zip, it deletes (unlinks) the previous test.zip and therein lies the problem. If two, or more, users hit the site at the same time then a RACE condition may have one user getting something they didn't ask for or not getting anything at all. The complicated way I figure I could solve this would be to: 1. Generate a random string name for the file -- instead of test.zip, it could be ax12nhg34.zip. 2. Then when the user selects the download that would trigger a javascript routine that would send the name of the file to be deleted to a slave php script that would unlinks the file. I know this will work, but if the user never downloads the file, then the files accumulate on the server. Does anyone have a better idea? Thanks, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#276546) next »