-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set directory permissions with bulk() #140
Comments
its true that bulk and directory really don't account for mode on directories. theres a few issues with the way mode is handled on directories (which is a newer addition to archiver) but those appear to mainly be on windows due to stat returning a 06xx mode. ive been considering letting those data props also be functions that receive file data and return modified data as I really dont want to add another prop or argument. also, if ever in question of what is really used internally, the best way is to switch to the next version will most likely address mode issues once i finish the plugin overhaul. |
Ok, that's cool. Letting |
have a peak at 6688585 |
I left one comment on the commit, but that looks like it will work for me. Thanks for the quick turnaround! |
im not sure theres much case for logging in that instance, as by default itd fail since id honestly opt for breaking before implementing logging for that case. |
at the end of the day, using a function is an advanced use case, as such its NOT going to normalize or verify what you give it. you're expected to know what your doing when using it. |
Right, the issue isn't with the default zip.bulk([
{ expand: true, cwd: sourceDir, src: ['**'], data: function() { throw 'foo';} }
]); It will appear to work successfully because the If the error is less obvious (e.g. calling some other lib that throws in some circumstances), that's going to be a nightmare to debug. |
this should cover most cases without being too insane with checking. |
fyi if you need this right now, archiver@0.15.0 should now work as a semver match since 0.15.0-1 (alpha) is now published. |
that works, thanks! |
glad to hear, i usually don't publish for every change so alphas should still be mostly safe if not its good to hear about issues before final goes out. |
Yep. BTW, in case anyone else wants it, this is the function I'm using: function setData(data) {
data.stats || (data.stats = fs.statSync(path.join(sourceDir, data.name)));
if (data.stats.isDirectory()) {
data.mode = 0755; // octal
} else {
data.mode = 0644;
}
return data;
}; Doing a synchronous stat isn't ideal, but this code doesn't get run very often and (I think) it will at least ensure that the file doesn't get stat'd twice. |
yah, that should work ok since theres logic to check if stats are already set in _append. i think |
Cool. Thanks again! |
also, did you find out if the |
the code for that should be: zip.directory(sourceDir, false, setData); |
Yea, I just tried it out, and it looks like it does work. It also grabs the |
yah, this is where |
So I have a question on this as I have the same requirement as the OP, having to add dirs recursively and set the Can you confirm that this would not work recursively?
|
Hi, I have some code like this:
And I've noticed that when creating a .zip, the
mode
is applied to files but not directories. (The directory permissions on the disk are 755, but the resulting .zip has 700.)I'm working on a mac, and I believe I've seen similar behavior on linux, so I'm not sure if this is related to the other open bugs or not. Either way, if there is a feature that lets me set directory permissions when doing a bulk operation that would be ideal, because I know what output permissions I want regardless of what they are on disk.
(I glanced at the new
.directory()
method, but I didn't see anything different there. And I'm guessing that it would drop the .htaccess file, so it probably wouldn't work for me anyway.)Any thoughts? Should I just add a
directoryData
option and send a PR?The text was updated successfully, but these errors were encountered: