Re: Logic sought

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tedd wrote:
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


Everybody so far has had excellent descriptions of what to do. I would do almost everything they recommend. Except, if I had the hard drive space to make all the possible permutation and allow them to down load the file that someone else had created, I would do that. Rather then possibly rebuilding an identical file over and over again.

So, I guess I need to ask this question. Are their to many files in your download selection too make the number of possible zip archives out of the question to be cached? If that is the case, then I would delete old ones using a cron/task schedule type program. But I would do it much quicker, say every three to seven days.

if you are limited on space, you will need to protect yourself against bots that might try, accidentally of course, to to make you run out of HD space. At this point, you might have to build something into your php script to manage the file space consumption.

Jim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux