Skip to content

Commit

Permalink
Merge pull request #380 from qiniu/fix/ci
Browse files Browse the repository at this point in the history
CI 修复
  • Loading branch information
bachue authored Apr 21, 2021
2 parents a216f03 + c394c9b commit af5711d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 52 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ node_js:
- "11"

install:
- npm install
- npm install -g codecov
- npm install -g istanbul

before_script:
- export is_travis=true
- export is_travis=true
script:
- npm test
- istanbul cover ./node_modules/mocha/bin/_mocha --reporter test -- -R spec
- codecov

Expand Down
56 changes: 28 additions & 28 deletions qiniu/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.SECRET_KEY = '<DONT SEND YOUR SECRET KEY TO ANYONE>';

var defaultUserAgent = function () {
return 'QiniuNodejs/' + pkg.version + ' (' + os.type() + '; ' + os.platform() +
'; ' + os.arch() + '; )';
'; ' + os.arch() + '; )';
};

exports.USER_AGENT = defaultUserAgent();
Expand All @@ -16,15 +16,15 @@ exports.BLOCK_SIZE = 4 * 1024 * 1024; // 4MB, never change
exports.FormMimeUrl = 'application/x-www-form-urlencoded';
exports.FormMimeJson = 'application/json';
exports.FormMimeRaw = 'application/octet-stream';
exports.RS_HOST = 'http://rs.qiniu.com';
exports.RS_HOST = 'rs.qiniu.com';
exports.RPC_TIMEOUT = 120000; // 120s
exports.UC_HOST = 'uc.qbox.me';

// proxy
exports.RPC_HTTP_AGENT = null;
exports.RPC_HTTPS_AGENT = null;

exports.Config = function Config (options) {
exports.Config = function Config(options) {
options = options || {};
// use http or https protocol
this.useHttpsDomain = !!(options.useHttpsDomain || false);
Expand All @@ -51,31 +51,31 @@ exports.Zone = function (srcUpHosts, cdnUpHosts, ioHost, rsHost, rsfHost,
if (zoneSepIndex != -1) {
var zoneTag = ioTag.substring(zoneSepIndex + 1);
switch (zoneTag) {
case 'z1':
this.rsHost = 'rs-z1.qiniu.com';
this.rsfHost = 'rsf-z1.qiniu.com';
this.apiHost = 'api-z1.qiniu.com';
break;
case 'z2':
this.rsHost = 'rs-z2.qiniu.com';
this.rsfHost = 'rsf-z2.qiniu.com';
this.apiHost = 'api-z2.qiniu.com';
break;
case 'na0':
this.rsHost = 'rs-na0.qiniu.com';
this.rsfHost = 'rsf-na0.qiniu.com';
this.apiHost = 'api-na0.qiniu.com';
break;
case 'as0':
this.rsHost = 'rs-as0.qiniu.com';
this.rsfHost = 'rsf-as0.qiniu.com';
this.apiHost = 'api-as0.qiniu.com';
break;
default:
this.rsHost = 'rs.qiniu.com';
this.rsfHost = 'rsf.qiniu.com';
this.apiHost = 'api.qiniu.com';
break;
case 'z1':
this.rsHost = 'rs-z1.qiniu.com';
this.rsfHost = 'rsf-z1.qiniu.com';
this.apiHost = 'api-z1.qiniu.com';
break;
case 'z2':
this.rsHost = 'rs-z2.qiniu.com';
this.rsfHost = 'rsf-z2.qiniu.com';
this.apiHost = 'api-z2.qiniu.com';
break;
case 'na0':
this.rsHost = 'rs-na0.qiniu.com';
this.rsfHost = 'rsf-na0.qiniu.com';
this.apiHost = 'api-na0.qiniu.com';
break;
case 'as0':
this.rsHost = 'rs-as0.qiniu.com';
this.rsfHost = 'rsf-as0.qiniu.com';
this.apiHost = 'api-as0.qiniu.com';
break;
default:
this.rsHost = 'rs.qiniu.com';
this.rsfHost = 'rsf.qiniu.com';
this.apiHost = 'api.qiniu.com';
break;
}
}
}
Expand Down
47 changes: 24 additions & 23 deletions qiniu/storage/rs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const util = require('../util');
exports.BucketManager = BucketManager;
exports.PutPolicy = PutPolicy;

function BucketManager (mac, config) {
function BucketManager(mac, config) {
this.mac = mac || new digest.Mac();
this.config = config || new conf.Config();
}
Expand All @@ -28,7 +28,7 @@ BucketManager.prototype.stat = function (bucket, key, callbackFunc) {
});
};

function statReq (mac, config, bucket, key, callbackFunc) {
function statReq(mac, config, bucket, key, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var statOp = exports.statOp(bucket, key);
var requestURI = scheme + config.zone.rsHost + statOp;
Expand All @@ -53,7 +53,7 @@ BucketManager.prototype.changeMime = function (bucket, key, newMime,
});
};

function changeMimeReq (mac, config, bucket, key, newMime, callbackFunc) {
function changeMimeReq(mac, config, bucket, key, newMime, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var changeMimeOp = exports.changeMimeOp(bucket, key, newMime);
var requestURI = scheme + config.zone.rsHost + changeMimeOp;
Expand All @@ -78,7 +78,7 @@ BucketManager.prototype.changeHeaders = function (bucket, key, headers,
});
};

function changeHeadersReq (mac, config, bucket, key, headers, callbackFunc) {
function changeHeadersReq(mac, config, bucket, key, headers, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var changeHeadersOp = exports.changeHeadersOp(bucket, key, headers);
var requestURI = scheme + config.zone.rsHost + changeHeadersOp;
Expand Down Expand Up @@ -107,7 +107,7 @@ BucketManager.prototype.move = function (srcBucket, srcKey, destBucket, destKey,
});
};

function moveReq (mac, config, srcBucket, srcKey, destBucket, destKey,
function moveReq(mac, config, srcBucket, srcKey, destBucket, destKey,
options, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var moveOp = exports.moveOp(srcBucket, srcKey, destBucket, destKey, options);
Expand Down Expand Up @@ -137,7 +137,7 @@ BucketManager.prototype.copy = function (srcBucket, srcKey, destBucket, destKey,
});
};

function copyReq (mac, config, srcBucket, srcKey, destBucket, destKey,
function copyReq(mac, config, srcBucket, srcKey, destBucket, destKey,
options, callbackFunc) {
options = options || {};
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
Expand All @@ -162,7 +162,7 @@ BucketManager.prototype.delete = function (bucket, key, callbackFunc) {
});
};

function deleteReq (mac, config, bucket, key, callbackFunc) {
function deleteReq(mac, config, bucket, key, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var deleteOp = exports.deleteOp(bucket, key);
var requestURI = scheme + config.zone.rsHost + deleteOp;
Expand All @@ -187,7 +187,7 @@ BucketManager.prototype.deleteAfterDays = function (bucket, key, days,
});
};

function deleteAfterDaysReq (mac, config, bucket, key, days, callbackFunc) {
function deleteAfterDaysReq(mac, config, bucket, key, days, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var deleteAfterDaysOp = exports.deleteAfterDaysOp(bucket, key, days);
var requestURI = scheme + config.zone.rsHost + deleteAfterDaysOp;
Expand All @@ -211,7 +211,7 @@ BucketManager.prototype.fetch = function (resUrl, bucket, key, callbackFunc) {
});
};

function fetchReq (mac, config, resUrl, bucket, key, callbackFunc) {
function fetchReq(mac, config, resUrl, bucket, key, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var encodedEntryURI = util.encodedEntry(bucket, key);
var encodedResURL = util.urlsafeBase64Encode(resUrl);
Expand All @@ -236,7 +236,7 @@ BucketManager.prototype.prefetch = function (bucket, key, callbackFunc) {
});
};

function prefetchReq (mac, config, bucket, key, callbackFunc) {
function prefetchReq(mac, config, bucket, key, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var encodedEntryURI = util.encodedEntry(bucket, key);
var requestURI = scheme + config.zone.ioHost + '/prefetch/' + encodedEntryURI;
Expand All @@ -261,7 +261,7 @@ BucketManager.prototype.changeType = function (bucket, key, newType,
});
};

function changeTypeReq (mac, config, bucket, key, newType, callbackFunc) {
function changeTypeReq(mac, config, bucket, key, newType, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var changeTypeOp = exports.changeTypeOp(bucket, key, newType);
var requestURI = scheme + config.zone.rsHost + changeTypeOp;
Expand Down Expand Up @@ -318,7 +318,7 @@ BucketManager.prototype.listPrefix = function (bucket, options, callbackFunc) {
});
};

function listPrefixReq (mac, config, bucket, options, callbackFunc) {
function listPrefixReq(mac, config, bucket, options, callbackFunc) {
options = options || {};
// 必须参数
var reqParams = {
Expand Down Expand Up @@ -376,7 +376,7 @@ BucketManager.prototype.listPrefixV2 = function (bucket, options, callbackFunc)
});
};

function listPrefixReqV2 (mac, config, bucket, options, callbackFunc) {
function listPrefixReqV2(mac, config, bucket, options, callbackFunc) {
options = options || {};
// 必须参数
var reqParams = {
Expand Down Expand Up @@ -417,7 +417,8 @@ function listPrefixReqV2 (mac, config, bucket, options, callbackFunc) {

// 批量文件管理请求,支持stat,chgm,chtype,delete,copy,move
BucketManager.prototype.batch = function (operations, callbackFunc) {
var requestURI = conf.RS_HOST + '/batch';
var scheme = this.config.useHttpsDomain ? 'https://' : 'http://';
var requestURI = scheme + conf.RS_HOST + '/batch';
var reqParams = {
op: operations
};
Expand Down Expand Up @@ -540,7 +541,7 @@ BucketManager.prototype.updateObjectStatus = function (bucket, key, status,
});
};

function updateStatusReq (mac, config, bucket, key, status, callbackFunc) {
function updateStatusReq(mac, config, bucket, key, status, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var changeStatusOp = exports.changeStatusOp(bucket, key, status);
var requestURI = scheme + config.zone.rsHost + changeStatusOp;
Expand Down Expand Up @@ -582,7 +583,7 @@ BucketManager.prototype.putBucketLifecycleRule = function (bucket, options,
PutBucketLifecycleRule(this.mac, this.config, bucket, options, callbackFunc);
};

function PutBucketLifecycleRule (mac, config, bucket, options, callbackFunc) {
function PutBucketLifecycleRule(mac, config, bucket, options, callbackFunc) {
options = options || {};
var reqParams = {
bucket: bucket,
Expand Down Expand Up @@ -691,7 +692,7 @@ BucketManager.prototype.putBucketEvent = function (bucket, options, callbackFunc
PutBucketEvent(this.mac, this.config, options, bucket, callbackFunc);
};

function PutBucketEvent (mac, config, options, bucket, callbackFunc) {
function PutBucketEvent(mac, config, options, bucket, callbackFunc) {
options = options || {};
var reqParams = { // 必填参数
bucket: bucket,
Expand Down Expand Up @@ -736,7 +737,7 @@ BucketManager.prototype.updateBucketEvent = function (bucket, options, callbackF
UpdateBucketEvent(this.mac, this.config, options, bucket, callbackFunc);
};

function UpdateBucketEvent (mac, config, options, bucket, callbackFunc) {
function UpdateBucketEvent(mac, config, options, bucket, callbackFunc) {
options = options || {};
var reqParams = {
bucket: bucket,
Expand Down Expand Up @@ -806,7 +807,7 @@ BucketManager.prototype.putReferAntiLeech = function (bucket, options, callbackF
PutReferAntiLeech(this.mac, this.config, bucket, options, callbackFunc);
};

function PutReferAntiLeech (mac, config, bucket, options, callbackFunc) {
function PutReferAntiLeech(mac, config, bucket, options, callbackFunc) {
options = options || {};
var reqParams = {
bucket: bucket
Expand Down Expand Up @@ -848,7 +849,7 @@ BucketManager.prototype.putCorsRules = function (bucket, body, callbackFunc) {
PutCorsRules(this.mac, this.config, bucket, body, callbackFunc);
};

function PutCorsRules (mac, config, bucket, body, callbackFunc) {
function PutCorsRules(mac, config, bucket, body, callbackFunc) {
var reqBody = JSON.stringify(body);
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var requestURI = scheme + conf.UC_HOST + '/corsRules/set/' + bucket;
Expand All @@ -861,7 +862,7 @@ BucketManager.prototype.getCorsRules = function (bucket, callbackFunc) {
GetCorsRules(this.mac, this.config, bucket, callbackFunc);
};

function GetCorsRules (mac, config, bucket, callbackFunc) {
function GetCorsRules(mac, config, bucket, callbackFunc) {
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
var requestURI = scheme + conf.UC_HOST + '/corsRules/get/' + bucket;
var digest = util.generateAccessToken(mac, requestURI, null);
Expand Down Expand Up @@ -976,14 +977,14 @@ BucketManager.prototype.listBucketDomains = function (bucket, callbackFunc) {
//解冻归档存储文件
BucketManager.prototype.restoreAr = function (entry, freezeAfterDays, callbackFunc) {
var scheme = this.config.useHttpsDomain ? 'https://' : 'http://';
var requestURI = scheme + conf.RS_QBOX + "/restoreAr/"+util.urlsafeBase64Encode(entry)+"/freezeAfterDays/"+freezeAfterDays;
var requestURI = scheme + conf.RS_HOST + "/restoreAr/" + util.urlsafeBase64Encode(entry) + "/freezeAfterDays/" + freezeAfterDays;
var digest = util.generateAccessToken(this.mac, requestURI, null);
rpc.postWithoutForm(requestURI, digest, callbackFunc);
};

// 上传策略
// @link https://developer.qiniu.com/kodo/manual/1206/put-policy
function PutPolicy (options) {
function PutPolicy(options) {
if (typeof options !== 'object') {
throw new Error('invalid putpolicy options');
}
Expand Down

0 comments on commit af5711d

Please sign in to comment.