diff --git a/lib/index.js b/lib/index.js index e06e0fc..2e35f48 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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); @@ -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 { @@ -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;