I have two PHP services. One that let other users to download a file. Another that fetch every some time an updated version of that file. Now I am implementing it through flock(). I thought of improving it by using link() - I mean downloading the file and then link to the new downloaded file. But, there is a problem with this way because you cannot link() a file that is already is being link.
Any ideas?
Download the new file to a temporary filename and then move it over to the real filename. No need to deal with links or locks. Your filesystem normally knows what it does.
Just add some error checking and deal with errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With