Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit ee4ef60

Browse files
committed
Clean dirStat when uploading directories
When uploading dirs to a different box and/or OS, the dirstat can contain an owner/group ids that aren't available at the destination. This can result in PERMISSION DENIED errors when the target user tries to create files with an incorrect u(g)id. This change only propagates file mode to the destination. The files will be owned by the remote user.
1 parent b27058d commit ee4ef60

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/client.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,14 @@ Client.prototype.upload = function(src, dest, callback) {
252252
},
253253
function(stat, callback) {
254254
if (stat.isDirectory()) return callback(new Error('Can not upload a directory'));
255-
255+
256256
// Get the attributes of the source directory
257257
fs.stat(path.dirname(src), function(err, dirStat) {
258258
if(err) return callback(err);
259-
self.mkdir(path.dirname(dest), dirStat, function(err){ callback(err, stat) });
259+
260+
var cleanDirStat = {mode: dirStat.mode};
261+
262+
self.mkdir(path.dirname(dest), cleanDirStat, function(err){ callback(err, stat) });
260263
});
261264
},
262265
function(stat, callback) {

0 commit comments

Comments
 (0)