简体   繁体   English

为什么PHP不会创建此zip文件(权限问题)

[英]Why won't PHP create this zip file (permissions issue)

  • I am on windows 我在窗户上

  • I am using PHING to zip up some files 我正在使用PHING压缩一些文件

  • I have lots of things being zipped 我有很多东西被压缩

  • Zipping works, except for ones that include a particular phing fileset in the files being zipped 压缩工作,但在压缩文件中包含特定phing文件集的工作除外

  • When I debug, I can see in phing's ZIP Task that ZipArchive::close is returning false. 当我调试时,我可以在phing的ZIP任务中看到ZipArchive :: close返回false。 The error string reads "permission denied". 错误字符串显示“权限被拒绝”。 In the manual it states close() is what actually writes the file. 在手册中声明close()是实际写入文件的内容。

  • It is not temporal coupling, in other words it happens wether this one is first, last or whatever. 它不是时间耦合,换句话说,它发生在第一个,最后一个或其他什么。 All the other ones work. 所有其他的工作。 There is seemingly nothing different about this one. 这个似乎没什么不同。

Here is my build file: http://pastebin.org/84786 (good for one month) 这是我的构建文件: http//pastebin.org/84786 (好一个月)

The problem is at line 251. The zip tasks preceding and following it both work fine. 问题出在第251行。在它之前和之后的zip任务都可以正常工作。 In the debugger I can see about 150 files are added to the zip. 在调试器中,我可以看到大约150个文件被添加到zip中。 I have verified all the paths to be correct in the debugger. 我已经验证了调试器中所有正确的路径。

The build seems to work fine on linux. 构建似乎在linux上运行良好。

When I right click the folder where the zip files are going, the read only check box is "blued out", not checked or unchecked. 当我右键单击zip文件所在的文件夹时,只读复选框为“蓝色”,未选中或未选中。 Wether I leave it checked or unchecked and press ok and go back into the folder's properties, the checkbox is "blue" again. 我保持选中或取消选中并按下确定并返回文件夹的属性,复选框再次为“蓝色”。 Apparently this is by design ( http://support.microsoft.com/kb/326549 ) and this does not seem like the problem since it happens only with that one file. 显然这是设计( http://support.microsoft.com/kb/326549 ),这似乎不是问题,因为它只发生在那个文件。

The other weird thing is if I go to line 252 and change the fileset to point at, for example, the files from the "importer" module right above it, it creates the zip. 另一个奇怪的事情是,如果我转到第252行并将文件集更改为指向例如来自其上方“importer”模块的文件,则会创建zip。 However the .tar.gz on line 236 the same fileset proves to work fine every time. 然而,第236行的.tar.gz相同的文件集证明每次都能正常工作。 So it only happens with the specific file set for zip tasks. 所以它只发生在zip任务的特定文件集中。 The file set works fine with the tar task. 该文件集适用于tar任务。 In fact all the tasks under the "package" comments below it that also reference those files do not get created, but the tar.gz files do. 实际上,在它下面的“package”注释下的所有任务也引用了那些文件,但tar.gz文件却没有。

What gives? 是什么赋予了?

Also: new observation... looks like on both Windows machines if I refresh file view fast enough I can see myzipfile.zip.tmp being built up, but myzipfile.zip never gets created. 另外:新的观察...看起来在两台Windows机器上如果我足够快地刷新文件视图我可以看到myzipfile.zip.tmp正在构建,但myzipfile.zip永远不会被创建。

On linux I just double checked everything is working flawlessly. 在linux上我只是仔细检查了一切是否完美无缺。 Go figure. 去搞清楚。

After your new observation, it sounds like the problem has to do with renaming the TMP file to the real ZIP file. 在您的新观察之后,听起来问题与将TMP文件重命名为真实的ZIP文件有关。 Either there's a filename issue, or there's some kind of delayed write problem where the file's not completely done yet at the time of rename. 要么存在文件名问题,要么存在某种延迟写入问题,其中文件在重命名时尚未完全完成。

I haven't seen the code in question, but I was having a similar problem. 我没有看到有问题的代码,但我遇到了类似的问题。 It occured due to the code using forward slashes rather than back slashes. 它是由于代码使用正斜杠而不是反斜杠而发生的。 I changed the slashes and had to escape them (\\\\). 我改变了斜线,不得不逃避它们(\\\\)。 Don't know if that helps but sometimes it is the little things that cause the biggest problems. 不知道这是否有帮助,但有时它是引起最大问题的小事。

Based on what you say about it working on Linux/Unix I would guess that you got hit by a difference in filesystem/locking semantics. 根据你在Linux / Unix上的说法,我猜你会受到文件系统/锁定语义差异的影响。 In Unix files are only voluntarilly locked (other programs can still read them when they are not "locking aware"). 在Unix文件中只有自动锁定(其他程序在没有“锁定意识”时仍然可以读取它们)。 In windows locking is enforced by the operating system meaning that you cannot read all files if they are in use by another program, and certainly not remove them (you must have had the error messages for that one). 在Windows中,操作系统强制执行锁定,这意味着如果所有文件都被其他程序使用,则无法读取所有文件,当然也不能删除它们(您必须拥有该文件的错误消息)。 If I have to guess, you're trying to zip up a file that is locked by an active process and it fails. 如果我不得不猜测,您正在尝试压缩由活动进程锁定的文件,但它会失败。 (As your other zip operations work I assume that writing is not a problem, and you have enough disk space/quota (and are not writing files bigger than 2GB on a FAT filesystem)) (正如你的其他zip操作工作我认为写入不是问题,并且你有足够的磁盘空间/配额(并且在FAT文件系统上没有写入大于2GB的文件))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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