bash Zip 文件损坏超过 4 GB - 没有警告或错误 - 我丢失了数据吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27151176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Zip files corrupt over 4 gigabytes - No warnings or errors - Did I lose my data?
提问by MikeC8
I created a bunch of zip files on my computer (Mac OS X) using a command like this:
我使用如下命令在我的计算机 (Mac OS X) 上创建了一堆 zip 文件:
zip -r bigdirectory.zip bigdirectory
Then, I saved these zip files somewhere and deleted the original directories.
然后,我将这些 zip 文件保存在某处并删除了原始目录。
Now, when I try to extract the zip files, I get this kind of error:
现在,当我尝试解压缩 zip 文件时,出现此类错误:
$ unzip -l bigdirectory.zip
Archive: bigdirectory.zip
warning [bigdirectory.zip]: 5162376229 extra bytes at beginning or within zipfile
(attempting to process anyway)
error [bigdirectory.zip]: start of central directory not found;
zipfile corrupt.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
I have since discovered that this could be because zip can't handle files over a certain size, maybe 4 gigs. At least I read that somewhere.
我后来发现这可能是因为 zip 无法处理超过特定大小的文件,可能是 4 个演出。至少我在某处读到过。
But why would the zip command let me create these files? The zip file in question is 9457464293 bytes and it let me make many more like this with absolutely no errors.
但是为什么 zip 命令会让我创建这些文件?有问题的 zip 文件是 9457464293 字节,它让我制作更多这样的文件,绝对没有错误。
So clearly it can create these files.
很明显它可以创建这些文件。
I really hope my files aren't lost. I've learned my lesson and in the future I will check my archives before deleting the original files, and I'll probably also use another file format like tar/gzip.
我真的希望我的文件不会丢失。我已经吸取了教训,将来我会在删除原始文件之前检查我的档案,我可能还会使用其他文件格式,如 tar/gzip。
For now though, what can I do? I really need my files.
不过现在,我能做什么?我真的需要我的文件。
Update
更新
Some people have suggested that my unzip
tool did not support big enough files (which is weird, because I used the builtin OS X zip
and unzip
). At any rate, I installed a new unzip
from homebrew
, and lo and behold, I do get a different error now:
有些人建议我的unzip
工具不支持足够大的文件(这很奇怪,因为我使用了内置的 OS Xzip
和unzip
)。无论如何,我安装了一个新的unzip
from homebrew
,瞧,我现在确实遇到了不同的错误:
$ unzip -t bigdirectory.zip
testing: bigdirectory/1.JPG OK
testing: bigdirectory/2.JPG OK
testing: bigdiretoryy/3.JPG OK
testing: bigdirectory/4.JPG OK
:
:
file #289: bad zipfile offset (local header sig): 4294967295
(attempting to re-compensate)
file #289: bad zipfile offset (local header sig): 4294967295
file #290: bad zipfile offset (local header sig): 9457343448
file #291: bad zipfile offset (local header sig): 9457343448
file #292: bad zipfile offset (local header sig): 9457343448
file #293: bad zipfile offset (local header sig): 9457343448
:
:
This is really worrisome because I need these files back. And there were definitely no errors upon creation of this zip file using the system zip
tool. In fact, I made several of these at the same time and now they are all exhibiting the same problem.
这真的很令人担忧,因为我需要取回这些文件。使用系统zip
工具创建此 zip 文件时绝对没有错误。事实上,我同时制作了几个,现在它们都表现出同样的问题。
If the file really is corrupt, how do I fix it?
如果文件确实已损坏,我该如何修复?
Or, if it is not corrupt, how do I extract it?
或者,如果它没有损坏,我如何提取它?
回答by Georg
Unzip below 6 seemingly fails, use
解压下面6个貌似失败,用
jar -xf <zipfile>
if you have java installed, or yet another unzip before you write the file off.
如果您安装了 java,或者在您写下文件之前再次解压缩。
See: https://serverfault.com/questions/235139/how-to-unzip-files-bigger-than-4gb
请参阅:https: //serverfault.com/questions/235139/how-to-unzip-files-bigger-than-4gb
回答by noobcannon
I had a similar problem backing up a 12GB directory before performing a hard disk format. Funnily enough I used the same command as you.
在执行硬盘格式化之前,我在备份 12GB 目录时遇到了类似的问题。有趣的是,我使用了与您相同的命令。
I read around and found suggestions to run:
我四处阅读并找到了运行的建议:
zip -F
and
和
zip -FF
to try to fix the file.
尝试修复该文件。
Unfortunately these did not work and I still received errors.
不幸的是,这些没有用,我仍然收到错误。
After looking around some more, I found the ditto command and it worked perfectly against my original (untouched) zip file:
环顾四周后,我找到了同上命令,它与我原来的(未触及的)zip 文件完美匹配:
ditto -x -k original-file.zip dst-directory
-x to extract an archive
-k Specifies it to be a PKZip archive instead of the default CPIO
After using this command, I successfully extracted all of the files.
使用此命令后,我成功提取了所有文件。
回答by Serge Stroobandt
Try 7z x
尝试 7z x
I had the same issue with unzip %x
on Linux for a .zip
file larger than 4GB, compounded with a only DEFLATED entries can have EXT descriptor
error.
unzip %x
对于.zip
大于 4GB的文件,我在 Linux 上遇到了同样的问题,并且出现了only DEFLATED entries can have EXT descriptor
错误。
The command 7z x
resolved all my issues though.
该命令7z x
解决了我所有的问题。
Be careful though, the command 7z x
will extract all files with a path rooted in the current directory. The option -o
allows to specify an output directory.
不过要小心,该命令7z x
将提取所有路径以当前目录为根的文件。该选项-o
允许指定输出目录。
回答by Anon
The built-in macOS Archive Utility (which is the default used when you select something in Finder and go to File -> Compress "<item>") creates "corrupt" archives when a file in the archive is over 4 gigabytes in size or the size of the archive itself is over 4 gigabytes or you are trying to compress more than 65536 into a single zip because it doesn't use the Zip64 extension format.
当存档中的文件大小超过 4 GB 或存档本身的大小超过 4 GB,或者您试图将超过 65536 的文件压缩到一个 zip 文件中,因为它不使用 Zip64 扩展格式。
Technically, all of the data from the files that have been compressed are still in the archive but the headers that allow fast listing of the zip's content is broken. Such zips can be a struggle to work with when using other tools (even testing such a zip with the command line unzip
tool on the same version of macOS can indicate issues like invalid compressed data to inflate
/ bad zipfile offset (local header sig)
) but Archive Utility can extract them fine (and any tool that ignores the standards and doesn't try to check/list the files first will likely also work).
从技术上讲,来自已压缩文件的所有数据仍在存档中,但允许快速列出 zip 内容的标头已损坏。在使用其他工具时,这样的 zip 可能很难处理(即使unzip
在相同版本的 macOS 上使用命令行工具测试这样的 zip也可以表明invalid compressed data to inflate
/ 之类的问题bad zipfile offset (local header sig)
),但 Archive Utility 可以很好地提取它们(以及任何忽略标准并且不尝试首先检查/列出文件也可能会起作用)。
This is mentioned on https://apple.stackexchange.com/questions/221020/large-zip-files-created-in-os-x-cannot-be-opened-in-windowsand is well covered in the "Apple Archive Utility (and ditto) and very large ZIP archives"2009 blog post for the now defunct Springy utility. You can also see the 7-Zip folks are aware of the Apple tools creating corrupt zips issuetoo.
这是在https://apple.stackexchange.com/questions/221020/large-zip-files-created-in-os-x-cannot-be-opened-in-windows上提到的,并且在“Apple Archive实用程序(和同上)和非常大的 ZIP 档案”2009 博客文章,用于现已解散的 Springy 实用程序。您还可以看到7-Zip 人员也知道 Apple 工具会导致损坏的 zip 问题。
回答by kmario23
I have faced exactly the same issue when I tried to unzip
zip files of huge sizes (~7GB). I was damn sure that there was no error while copying the zip files to the server. (I double-checked it with rsync
).
当我尝试unzip
压缩大尺寸(~7GB)的文件时,我遇到了完全相同的问题。我非常确定将 zip 文件复制到服务器时没有错误。(我用 仔细检查了它rsync
)。
Depending on your situation, the solution is:
根据您的情况,解决方案是:
1) If you're doing this in a local machine, right click on the zip file and give Extract Here
, this will work for (.zip) files of any size.
1) 如果您在本地机器上执行此操作,请右键单击 zip 文件并给出Extract Here
,这将适用于任何大小的 (.zip) 文件。
2) If your zip files are in a remote server, first load the server filesystem locally using sftp
(sftp://[email protected]
). After that just navigate to the directory and again do the same thing as you did in (1). i.e. right click on the zip file and extract it.
2) 如果您的 zip 文件位于远程服务器中,请首先使用sftp
( sftp://[email protected]
)在本地加载服务器文件系统。之后只需导航到目录并再次执行与(1)中相同的操作。即右键单击 zip 文件并将其解压缩。
Might not be the best solution but that's one way of doing it.
可能不是最好的解决方案,但这是一种方法。