Skip to content

Zipping broken #79

Closed
silverwind opened this Issue Mar 6, 2014 · 33 comments

3 participants

@silverwind
Owner

Looking into it.

@silverwind silverwind self-assigned this Mar 6, 2014
@silverwind
Owner

That'll teach me not to blindly update deps :cry:

archiverjs/node-archiver@d8021ad

@silverwind silverwind closed this in 54b8447 Mar 6, 2014
@ctalkington

@silverwind was just browsing projects using archiver. sorry about this. i try to refrain from such breaking changes (even with semver) but sometimes needed to get to point b.

@ctalkington

also, you may be able to replace utils.walkDirectory with bulk() using the below or something like it. It will filter it to files only internally and act similar to file():

archive.bulk([
  { expand: true, cwd: zipPath, src: ['**'] }
]);

https://github.com/ctalkington/node-archiver#bulkmappings

@ZombieHippie
Collaborator

Looks cool @ctalkington

@silverwind
Owner

Thank, I really appreciate your feedback.

I was looking at .bulk before, but wasn't sure which globbing pattern to use, I'll try yours.

The breakage was unexpected, but totally my fault, as I ran npm-check-updates without looking up the module changes. Now, I still run the update check before each release, but I'm reading the commit log or the (rare) changelog of modules now.

@silverwind
Owner

@ctalkington Seems to work nicely so far, only caveat I found is, that when zipping an empty directory, it won't get included in the zip. I'm not sure I can fix this on my side, could you check that out?

@ctalkington

can you elaborate? im guessing you mean that zipPath contains no files so bulk doesnt run, producing an empty zip?

@silverwind
Owner
archive.bulk([{ expand: true, cwd: zipPath, src: ["**"], dest: path.basename(zipPath)}]);

Assuming zipPath is /path/to/folder, dest resolves to folder, which is empty. I explicitly want to include the zipped folder in the zip itself, so there are no bad suprises with files spilling into the directory when unzipping.

I think .bulk() still runs but all I get is a 22 byte, emtpy zip file.

@ctalkington

i think the best thing i can recommend is going to be doing a manual directory entry just before bulk since the way those bulk are run across and such. that said i need to update node-zip-stream support directories. i will work to get this out asap as I see the value in it.

@silverwind
Owner

Manually adding the root directory could work, but what if it encounters an empty directory somewhere deeper in the path? I'll eagerly await your updates :)

@ctalkington

the code would end up being something like (once proper directory support is there):

archive.entry(null, { name: path.basename(zipPath), type: 'directory' });

the globbing itself does pickup the dirs, just filtered out internally atm since writing every directory when it has a file is a bit overfill imho. what i really want to do here is:

a. support type: directory
b. when bulk gets a directory, add it to a list that then is filtered to see if another file path is inside it. and add all the empty dirs at end of archive.

@silverwind
Owner

Sounds great!

@ctalkington

should be roll out an update today. just working out some aspects on both archiver and zip-stream

@ctalkington

@silverwind give archiver v0.8.0 a go ;)

@ctalkington

also it would be the following to enforce a folder inside even if source dir is empty:

archive.append(null, { name: path.basename(zipPath) + '/' });
@silverwind
Owner

I'm a bit confused as to where to put the absolute path to the directory. Is archiver.entry the correct function?

archive.entry(zipPath, { name: path.basename(zipPath), type: 'directory' });

The above gave me Object [object Object] has no method 'entry', thought it may just be my npm acting up, I get all kind of strange JSON errors when installing dependencies right now.

@ctalkington

yah entry is zip-stream. you'd want append for archiver. sorry about that.

@ctalkington

should look like this i think:

archive.append(null, { name: path.basename(zipPath) + '/' });
archive.bulk(...);
@silverwind
Owner

Oh, alright. Didn't realize you reworked .bulk after all.

@ctalkington

yes, the only thing the recent changes don't do is filter out redundant directory entries, i figured best to have the little extra size and ability to add empty dirs for now. will revisit for optimization in future release.

@silverwind
Owner

Looking good so far. I noticed something, that might be a bug:

archive.bulk([{ expand: true, cwd: zipPath, src: ["**"]}]);

Running the above (note, no dest) on an empty dir gives an zip with an . file in it. WinRAR thinks it's an "Local Disk".

@silverwind
Owner

rar

@ctalkington

thats most likely more to do with the expand logic from grunt, which expects a dest to be set.

EDIT: hum actually, it may be something else as i've used without dest before.

@silverwind
Owner

Works flawlessly with a dest thought, thanks again!

@silverwind
Owner

Should I open an issue at archiver, or do you wanna fix it on the fly?

@ctalkington

if you want to reg an issue that would be good. ill have to write a test or two and try and narrow why it happens. initial testing appears fine locally. what OS do you use, something similar on windows returns empty array which shouldn't cause anything to be added.

EDIT: caught it in action. feel free to file the issue though.

@silverwind
Owner

This test was on Windows, will test on other platforms and then do an issue.

@ctalkington

see archiverjs/node-archiver@d684de8. thanks for the testing. its just the way glob handles ** in cwd.

@silverwind
Owner

Ah, I' check this out. I just finished testing on OS X and it showed me ".-1" as an errounous entry with a client on the same machine. Though I used a different zip utility over there.

@silverwind
Owner

Looks good now. I get the expected 22 byte zip files without contents.

@ctalkington

@silverwind glad to hear, do let me know if you run into anything in the future. i try to push out fixes asap.

@silverwind
Owner

If you could do a patch release, that would be great :)

Edit: nevermind, I see you did already.

@ctalkington

already done, npm is just a tad slow.

@silverwind silverwind added a commit that referenced this issue Apr 1, 2014
@silverwind #79 Update archiver to 0.8.1 b458f6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.