Skip to content

Commit d5131ef

Browse files
committed
stat isn't reliable on windows; force 0755 for directories when sourced from stats. closes #136 #137. props @Tim-B.
1 parent a7b82f7 commit d5131ef

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/core.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ var util = require('./util');
1212
var inherits = require('util').inherits;
1313
var Transform = require('readable-stream').Transform;
1414

15+
var win32 = process.platform === 'win32';
16+
1517
var Archiver = module.exports = function(format, options) {
1618
if (!(this instanceof Archiver)) {
1719
return new Archiver(format, options);
@@ -196,11 +198,16 @@ Archiver.prototype._normalizeEntryData = function(data, stats) {
196198
}
197199
}
198200

199-
// 511 === 0777; 493 === 0755; 420 === 0644
201+
// 511 === 0777; 493 === 0755; 438 === 0666; 420 === 0644
200202
if (typeof data.mode === 'number') {
201203
data.mode &= 511;
202204
} else if (data.stats && data.mode === null) {
203205
data.mode = data.stats.mode & 511;
206+
207+
// stat isn't reliable on windows; force 0755 for dir
208+
if (win32 && isDir) {
209+
data.mode = 493;
210+
}
204211
} else if (data.mode === null) {
205212
data.mode = isDir ? 493 : 420;
206213
}

0 commit comments

Comments
 (0)