End-of-central-directory signature not found

You download a zip file only to find that it barfs when you try to un-archive it:

$ unzip -t test.zip 
Archive:  test.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.

What a nightmare.

 

Now you’re left with the prospect of attempting to download again, or see if you can salvage what you have. Bandwidth is cheap, but the machine at the other end is no longer responding. Great… time to learn how to extract a partially downloaded / corrupt zip file!

It’s actually a lot easier than you might think… which makes me wonder why i’ve never learnt it before. First try a little force:

$ zip -F test.zip --out partial.zip
Fix archive (-F) - assume mostly intact archive
	zip warning: bad archive - missing end signature
	zip warning: (If downloaded, was binary mode used?  If not, the
	zip warning:  archive may be scrambled and not recoverable)
	zip warning: Can't use -F to fix (try -FF)

zip error: Zip file structure invalid (test.zip)

Nope. Now a little more force:

$ zip -FF test.zip --out partial.zip
Fix archive (-FF) - salvage what can
zip warning: Missing end (EOCDR) signature - either this archive
is not readable or the end is damaged
Is this a single-disk archive? (y/n): y
Assuming single-disk archive
Scanning for entries...
copying: selected exported/3 monkeys.jpg (2629234 bytes)
...
copying: selected exported/worried and walking.jpg (21563355 bytes)
Central Directory found...
zip warning: reading central directory: Undefined error: 0
zip warning: bad archive - error reading central directory
zip warning: skipping this entry...

Good to go?

$ unzip -qt partial.zip 
No errors detected in compressed data of partial.zip.

Good to go!

Advertisements

Imagination Lacking

Untitled.jpeg

Trying to imagine what my life would have to be like to live through that week of Tory arse-hattery and think, “you know what we need? we need more arse-hattery!”.

It becomes increasingly difficult to express sympathy.