dtzd65908 2013-09-24 12:42
浏览 30
已采纳

删除包含客户端当前正在下载的文件的目录

Imagine the following scenario:

  • Client (browser) calls a PHP script
  • Script generates a ZIP file in web_root/downloads/tmp/test.zip
  • Script returns headers accordingly and therefore initiates a download of that ZIP file
  • Script terminates the directory web_root/downloads/tmp/

What could happen?

  1. Server queues deletion and deletes folder as soon as possible
  2. Directory (and file) are deleted and the client therefore loses the connection
  3. Server declines deletion because directory is somehow locked
  4. Apache actually clones/caches files before streaming them, so that deleting the original will have no effect

Which one is correct?

Now, i could test this behaviour on my own server, but what i want to know is whether there exists any sort of convention that defines UNIX/LINUX based standard behaviour in such a case?

How are such cases handled in general?

  • 写回答

1条回答 默认 最新

  • duanrong0738 2013-09-24 12:47
    关注

    5. Apache has the filesystem inode open, so when you delete the file, it's not deleted, it's unlinked. That is, link web_root/downloads/tmp/test.zip is removed, but the inode still exists as long as apache has the inode open. When apache closes the inode, its link count reaches zero and is removed by the system

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统