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

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

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示