cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Locking files, A fun but useless game

From: Joe N. <jnardone_at_gmail.com>
Date: Sat, 19 Jul 2008 11:16:15 -0400

Garabled Sdjhsjd wrote:
> i can see all the files in the directory. Every dir has a major file to scan. It tells me what the important files are and which are useless + tons of other data to slow me down. Usually there are 25 or less files per directory. When i tell him i started the scan he will wait a few seconds, then move 3 file, wait another few seconds and move another few. a few of the important files are moved/renamed so i miss them. I need to grab them all w/o a rescan. I figure i can make his server stall the move or file rename by a request to DL of the file but not actually read it. Or i could do the transfer very slowly (2k per second? could i go slower?). I think i would need to lock the files for 80 seconds, which is resonable? Can i prevent 24 files from being renamed/moved? How should i lock them? even if i cant do them all a few would be good since i get a better hit ratio
>
Far as I know, there is nothing on the client side that you can do to
lock or otherwise hold files through FTP, SCP, or HTTP; it is entirely
up to the server (and I've never seen a server that locks the files to
prevent them from being moved.) There's nothing to stop him from moving
files out *while* you are transferring them, so a slow rate isn't going
to help you at all.

You will need to come up with a mutually agreeable mechanism for locking
the files at the application level, e.g. you create your own lock file
before downloading that he respects (and doesn't move files as long as
your lockfile is present.) It's still a race condition, because he
might start moving files right before you create the lock file. (Better
yet, create a lockfile for the directory, which keeps the other program
out of this directory as long as you are in it.) However, the problem
with app-created lockfiles is what happens when your app crashes and
doesn't remove the lock. The other program will never do what it's
trying to do (moving the files out of the directory.)

This whole design seems pretty convoluted. What is the point of what
you're trying to do?

joe
Received on 2008-07-19