@baiducloud/sdk
Advanced tools
Comparing version 1.0.0-rc.19 to 1.0.0-rc.20
{ | ||
"name": "@baiducloud/sdk", | ||
"version": "1.0.0-rc.19", | ||
"version": "1.0.0-rc.20", | ||
"description": "Baidu Cloud Engine JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -44,2 +44,3 @@ /** | ||
var MAX_PART_NUMBER = 10000; | ||
var MAX_RETRY_COUNT = 3; | ||
var COMMAND_MAP = { | ||
@@ -442,5 +443,21 @@ scale: 's', | ||
}; | ||
var fp = fs.createReadStream(filename, streamOptions); | ||
var me = this; | ||
function putObjectWithRetry(lastRetryTimes) { | ||
return me.putObject(bucketName, key, fs.createReadStream(filename, streamOptions), options) | ||
.catch(function (err) { | ||
var serverTimestamp = new Date(err[H.X_BCE_DATE]).getTime(); | ||
BceBaseClient.prototype.timeOffset = serverTimestamp - Date.now(); | ||
if (err[H.X_STATUS_CODE] === 400 && err[H.X_CODE] === 'Http400' && lastRetryTimes > 0) { | ||
return putObjectWithRetry(--lastRetryTimes); | ||
} | ||
return Q.reject(err); | ||
}); | ||
} | ||
if (!u.has(options, H.CONTENT_MD5)) { | ||
var me = this; | ||
var fp2 = fs.createReadStream(filename, streamOptions); | ||
@@ -450,7 +467,7 @@ return crypto.md5stream(fp2) | ||
options[H.CONTENT_MD5] = md5sum; | ||
return me.putObject(bucketName, key, fp, options); | ||
return putObjectWithRetry(options.retryCount || MAX_RETRY_COUNT); | ||
}); | ||
} | ||
return this.putObject(bucketName, key, fp, options); | ||
return putObjectWithRetry(options.retryCount || MAX_RETRY_COUNT); | ||
}; | ||
@@ -1016,3 +1033,3 @@ | ||
return doRequest.call(client).catch(function(err) { | ||
return doRequest.call(client).catch(function (err) { | ||
var serverTimestamp = new Date(err[H.X_BCE_DATE]).getTime(); | ||
@@ -1025,5 +1042,2 @@ | ||
} | ||
else if (err[H.X_STATUS_CODE] === 400 && err[H.X_CODE] === 'Http400') { | ||
return doRequest.call(client); | ||
} | ||
@@ -1030,0 +1044,0 @@ return Q.reject(err); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3337687
58454