Answer the question
In order to leave comments, you need to log in
PHP: Check if file is writable
There is a php script that reads the contents of a directory and processes the files.
How can I find out if a file is fully uploaded to a directory or is being uploaded?
Example: I copy a movie to a directory (it takes a long time to copy), the php script gets the contents of the directory, sees a new file and tries to do something with it, but the file itself is still being copied.
fopen perfectly opens such files even for writing, is_writable, is_readable and the like, they also say that everything is fine with the file, rename moves such a file perfectly (it turns out to be broken).
Answer the question
In order to leave comments, you need to log in
You can check file sizes. If the file size has not changed in a minute (several minutes, an hour, etc.), assume that it is completely filled.
Hmm... and try to open such a file with an exclusive lock? Or... perhaps FTP has some setting so that it would lock such a file for the duration of the recording.
I don't see any options other than how to lsof directories as root. running only lsof as root without entering a password can be implemented via sudoers.
Copy under one name (for example, by adding a dot or underscore to the beginning of the file name), write in the script that such files should be skipped. Rename the file after copying is complete.
I suspect that the FTP server writes to a local file in batches, buffering the incoming data and periodically dumping it to disk. If my assumption is correct, then between flushes, the file is not locked. If so, then, in the FTP server settings, there may be a corresponding checkbox to block the file throughout the entire upload process.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question