Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retry not working issue. Also add verbose log for error and retry… #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
19 changes: 17 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// 引入七牛 Node.js SDK
var qiniu = require('qiniu');

qiniu.conf.RPC_TIMEOUT = 10000;
/**
* 生成上传凭证并返回
*/
Expand All @@ -31,6 +32,13 @@ function uploadBuf(uptoken, release, content, file, callback) {

qiniu.io.put(uptoken, objkey, content, extra, function(err, ret) {
if(err){
var time = '[' + fis.log.now(true) + ']';
process.stdout.write(
' failUploadQiniu - '.green.bold +
time.grey + ' ' +
subpath.replace(/^\//, '') +
'\n'
);
console.log('error:', err);
callback(err);
} else {
Expand Down Expand Up @@ -78,10 +86,17 @@ module.exports = function(options, modified, total, callback, next) {
if (!--reTryCount) {
throw new Error(error);
} else {
_upload();
var time = '[' + fis.log.now(true) + ']';
process.stdout.write(
'#' + reTryCount + ' retryuploadQiniu - '.green.bold +
time.grey + ' ' +
file.subpath.replace(/^\//, '') +
'\n'
);
_upload(next);
}
} else {
next(); //由于是异步的如果后续还需要执行必须调用 next
next(); //由于是异步的如果后续还需要执行必须调用 next
}
});
});
Expand Down