Skip to content
This repository was archived by the owner on Feb 12, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ Client.prototype.downloadFile = function(params) {
if (statusCode >= 300) {
handleError(new Error("http status code " + statusCode));
return;
}
}
if (headers['content-length'] == undefined) {
var outStream = fs.createWriteStream(localFile);
outStream.on('error', handleError);
Expand All @@ -470,14 +470,14 @@ Client.prototype.downloadFile = function(params) {
downloader.progressTotal += chunk.length;
downloader.progressAmount += chunk.length;
downloader.emit('progress');
outStream.write(chunk);
outStream.write(chunk);
})

request.on('httpDone', function() {
request.on('httpDone', function() {
if (errorOccurred) return;
downloader.progressAmount += 1;
downloader.emit('progress');
outStream.end();
outStream.end();
cb();
})
} else {
Expand Down Expand Up @@ -1169,7 +1169,11 @@ function syncDir(self, params, directionIsToS3) {
function startUpload() {
ee.progressTotal += localFileStat.size;
var fullKey = prefix + localFileStat.s3Path;
upDownFileParams.s3Params.Key = fullKey;
if (!upDownFileParams.s3Params.Key) {
upDownFileParams.s3Params.Key = fullKey;
} else {
fullKey = upDownFileParams.s3Params.Key;
}
upDownFileParams.localFile = fullPath;
var uploader = self.uploadFile(upDownFileParams);
var prevAmountDone = 0;
Expand Down