PHP: How do I avoid reading partial files that are pushed to me with FTP?

后端 未结 7 1828
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 19:19

Files are being pushed to my server via FTP. I process them with PHP code in a Drupal module. O/S is Ubuntu and the FTP server is vsftp.

At regular intervals I will

相关标签:
7条回答
  • 2021-01-01 20:14

    Here's another idea: create a super (but hopefully not root) FTP user that can access some or all of the upload directories. Instead of your PHP code reading uploaded files right off the disk, make it connect to the local FTP server and download files. This way vsftpd handles the locking for you (assuming you leave lock_upload_files enabled). You'll only be able to download a file once vsftp releases the exclusive/write lock (once writing is complete).

    You mentioned trying flock in your comment (and how it fails). It does indeed seem painful to try to match whatever locking vsftpd is doing, but dio_fcntl might be worth a shot.

    0 讨论(0)
提交回复
热议问题