简体   繁体   中英

No file while renaming in PHP?

Thanks to a cron PHP process, some temporary files are created and then renamed (with rename() ) so as to replace files that users access.

Is it possible that a user requests a page while it's being replaced by renaming, and there is no file ? Is there such an "in-between time" (even very small) ?

If you were deleting the old file and moving a new one into it's place, it is certainly possible that some users will try to access a file that does not exist. If you are renaming it without deleting the old file (overwriting), you will not run into any issues if you're on Linux . You are out of luck if you're on windows though .

You would need to write your own locking procedure in the latter case, using flock() for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM