node-archiver icon indicating copy to clipboard operation
node-archiver copied to clipboard

--no-extra option for zip?

Open bbrcan opened this issue 6 years ago • 9 comments

Hi all,

I was just wondering if there's any support for the '--no-extra' zip option? This option just excludes metadata from being included in the zip archive.

Useful for when you need to ensure the md5 sum is the same every time you generate a zip file with the same files.

Thanks,

Ben

bbrcan avatar May 31 '18 05:05 bbrcan

what metadata does that exclude? I didnt think we set that much more than required for proper operation?

ctalkington avatar Jun 21 '18 23:06 ctalkington

Here's the manpage entry, for your convenience:

-X, --no-extra Do not save extra file attributes (Extended Attributes on OS/2, uid/gid and file times on Unix). The zip format uses extra fields to include additional information for each entry. Some extra fields are specific to particular systems while others are applicable to all systems. Normally when zip reads entries from an existing archive, it reads the extra fields it knows, strips the rest, and adds the extra fields applicable to that system. With -X, zip strips all old fields and only includes the Unicode and Zip64 extra fields (currently these two extra fields cannot be disabled).

Negating this option, -X-, includes all the default extra fields, but also copies over any unrecognized extra fields.

bbrcan avatar Jun 26 '18 05:06 bbrcan

I'm finding that I need this too.

With the --no-extra option, zipping a mimetype file along with my data allows Linux to guess the mimetype of the file. Without that option, it's not able to.

With -X:

zip -X my-archive.zip mimetype datadirectory/*
file my-archive.zip
#> my-archive.zip: Zip data (MIME type "application/vnd.gingko.tree-document"?)

Without -X:

zip my-archive.zip mimetype datadirectory/*
file my-archive.zip
#my-archive.zip: Zip archive data, at least v2.0 to extract

AdrianoFerrari avatar Jul 20 '18 18:07 AdrianoFerrari

@bbrcan @AdrianoFerrari use something like this: archive.file('src.js', { date: '2018-10-19T06:54:32.953Z' }), set the same date.

zhiquan-yu avatar Oct 19 '18 07:10 zhiquan-yu

@bbrcan @AdrianoFerrari use something like this: archive.file('src.js', { date: '2018-10-19T06:54:32.953Z' }), set the same date.

It doesn't work. We may have to find another way.

LangZhai avatar Dec 13 '18 07:12 LangZhai

Forcing the date doesn't work for me, either.

codeaholics avatar Jul 07 '19 23:07 codeaholics

can someone help on this one?

vigdora100 avatar Dec 10 '19 16:12 vigdora100

I also have this problem. Every time generating files have different md5 sum. I need to remove the extra file attributes.

ety001 avatar Feb 11 '20 10:02 ety001

add option like

{
  name: '123.txt',
  date: new Date('2000-01-01T00:00:00')
}

it's work for me

hunterlord avatar Apr 02 '23 17:04 hunterlord