in reply to When is it safe to move a file?
Use stat to compare the inode access/modify/change times for the data and control files. Also check that the control file is big enough to be finished. If all the inode times are near equal, and the files are resonable sizes, you may be able to assume the file is okay.
It would be better if filenames were always unique or the ftp server used flock or lockf on the files, but it may be possible to deal with your problem. I have no idea if this solution will work, I really don't know all that much about inodes and stuff.my $name = 'foo.txt'; my $cnrl_name = $name . '.ctrl'; if ( ((stat($cnrl_name))[9] > (stat($name))[9]) and ((-s($cnrl_name))> +10) ) { copy $name, "dir/$name"; unlink $name, $cnrl_name; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: When is it safe to move a file?
by BoredByPolitics (Scribe) on Jan 14, 2001 at 19:00 UTC | |
by Dominus (Parson) on Jan 14, 2001 at 22:23 UTC |