Skip to content

Commit af5711d

Browse files
authored
Merge pull request #380 from qiniu/fix/ci
CI 修复
2 parents a216f03 + c394c9b commit af5711d

File tree

3 files changed

+55
-52
lines changed

3 files changed

+55
-52
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ node_js:
77
- "11"
88

99
install:
10+
- npm install
1011
- npm install -g codecov
1112
- npm install -g istanbul
1213

1314
before_script:
14-
- export is_travis=true
15+
- export is_travis=true
1516
script:
17+
- npm test
1618
- istanbul cover ./node_modules/mocha/bin/_mocha --reporter test -- -R spec
1719
- codecov
1820

qiniu/conf.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports.SECRET_KEY = '<DONT SEND YOUR SECRET KEY TO ANYONE>';
66

77
var defaultUserAgent = function () {
88
return 'QiniuNodejs/' + pkg.version + ' (' + os.type() + '; ' + os.platform() +
9-
'; ' + os.arch() + '; )';
9+
'; ' + os.arch() + '; )';
1010
};
1111

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

2323
// proxy
2424
exports.RPC_HTTP_AGENT = null;
2525
exports.RPC_HTTPS_AGENT = null;
2626

27-
exports.Config = function Config (options) {
27+
exports.Config = function Config(options) {
2828
options = options || {};
2929
// use http or https protocol
3030
this.useHttpsDomain = !!(options.useHttpsDomain || false);
@@ -51,31 +51,31 @@ exports.Zone = function (srcUpHosts, cdnUpHosts, ioHost, rsHost, rsfHost,
5151
if (zoneSepIndex != -1) {
5252
var zoneTag = ioTag.substring(zoneSepIndex + 1);
5353
switch (zoneTag) {
54-
case 'z1':
55-
this.rsHost = 'rs-z1.qiniu.com';
56-
this.rsfHost = 'rsf-z1.qiniu.com';
57-
this.apiHost = 'api-z1.qiniu.com';
58-
break;
59-
case 'z2':
60-
this.rsHost = 'rs-z2.qiniu.com';
61-
this.rsfHost = 'rsf-z2.qiniu.com';
62-
this.apiHost = 'api-z2.qiniu.com';
63-
break;
64-
case 'na0':
65-
this.rsHost = 'rs-na0.qiniu.com';
66-
this.rsfHost = 'rsf-na0.qiniu.com';
67-
this.apiHost = 'api-na0.qiniu.com';
68-
break;
69-
case 'as0':
70-
this.rsHost = 'rs-as0.qiniu.com';
71-
this.rsfHost = 'rsf-as0.qiniu.com';
72-
this.apiHost = 'api-as0.qiniu.com';
73-
break;
74-
default:
75-
this.rsHost = 'rs.qiniu.com';
76-
this.rsfHost = 'rsf.qiniu.com';
77-
this.apiHost = 'api.qiniu.com';
78-
break;
54+
case 'z1':
55+
this.rsHost = 'rs-z1.qiniu.com';
56+
this.rsfHost = 'rsf-z1.qiniu.com';
57+
this.apiHost = 'api-z1.qiniu.com';
58+
break;
59+
case 'z2':
60+
this.rsHost = 'rs-z2.qiniu.com';
61+
this.rsfHost = 'rsf-z2.qiniu.com';
62+
this.apiHost = 'api-z2.qiniu.com';
63+
break;
64+
case 'na0':
65+
this.rsHost = 'rs-na0.qiniu.com';
66+
this.rsfHost = 'rsf-na0.qiniu.com';
67+
this.apiHost = 'api-na0.qiniu.com';
68+
break;
69+
case 'as0':
70+
this.rsHost = 'rs-as0.qiniu.com';
71+
this.rsfHost = 'rsf-as0.qiniu.com';
72+
this.apiHost = 'api-as0.qiniu.com';
73+
break;
74+
default:
75+
this.rsHost = 'rs.qiniu.com';
76+
this.rsfHost = 'rsf.qiniu.com';
77+
this.apiHost = 'api.qiniu.com';
78+
break;
7979
}
8080
}
8181
}

qiniu/storage/rs.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const util = require('../util');
88
exports.BucketManager = BucketManager;
99
exports.PutPolicy = PutPolicy;
1010

11-
function BucketManager (mac, config) {
11+
function BucketManager(mac, config) {
1212
this.mac = mac || new digest.Mac();
1313
this.config = config || new conf.Config();
1414
}
@@ -28,7 +28,7 @@ BucketManager.prototype.stat = function (bucket, key, callbackFunc) {
2828
});
2929
};
3030

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

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

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

110-
function moveReq (mac, config, srcBucket, srcKey, destBucket, destKey,
110+
function moveReq(mac, config, srcBucket, srcKey, destBucket, destKey,
111111
options, callbackFunc) {
112112
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
113113
var moveOp = exports.moveOp(srcBucket, srcKey, destBucket, destKey, options);
@@ -137,7 +137,7 @@ BucketManager.prototype.copy = function (srcBucket, srcKey, destBucket, destKey,
137137
});
138138
};
139139

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

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

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

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

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

264-
function changeTypeReq (mac, config, bucket, key, newType, callbackFunc) {
264+
function changeTypeReq(mac, config, bucket, key, newType, callbackFunc) {
265265
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
266266
var changeTypeOp = exports.changeTypeOp(bucket, key, newType);
267267
var requestURI = scheme + config.zone.rsHost + changeTypeOp;
@@ -318,7 +318,7 @@ BucketManager.prototype.listPrefix = function (bucket, options, callbackFunc) {
318318
});
319319
};
320320

321-
function listPrefixReq (mac, config, bucket, options, callbackFunc) {
321+
function listPrefixReq(mac, config, bucket, options, callbackFunc) {
322322
options = options || {};
323323
// 必须参数
324324
var reqParams = {
@@ -376,7 +376,7 @@ BucketManager.prototype.listPrefixV2 = function (bucket, options, callbackFunc)
376376
});
377377
};
378378

379-
function listPrefixReqV2 (mac, config, bucket, options, callbackFunc) {
379+
function listPrefixReqV2(mac, config, bucket, options, callbackFunc) {
380380
options = options || {};
381381
// 必须参数
382382
var reqParams = {
@@ -417,7 +417,8 @@ function listPrefixReqV2 (mac, config, bucket, options, callbackFunc) {
417417

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

543-
function updateStatusReq (mac, config, bucket, key, status, callbackFunc) {
544+
function updateStatusReq(mac, config, bucket, key, status, callbackFunc) {
544545
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
545546
var changeStatusOp = exports.changeStatusOp(bucket, key, status);
546547
var requestURI = scheme + config.zone.rsHost + changeStatusOp;
@@ -582,7 +583,7 @@ BucketManager.prototype.putBucketLifecycleRule = function (bucket, options,
582583
PutBucketLifecycleRule(this.mac, this.config, bucket, options, callbackFunc);
583584
};
584585

585-
function PutBucketLifecycleRule (mac, config, bucket, options, callbackFunc) {
586+
function PutBucketLifecycleRule(mac, config, bucket, options, callbackFunc) {
586587
options = options || {};
587588
var reqParams = {
588589
bucket: bucket,
@@ -691,7 +692,7 @@ BucketManager.prototype.putBucketEvent = function (bucket, options, callbackFunc
691692
PutBucketEvent(this.mac, this.config, options, bucket, callbackFunc);
692693
};
693694

694-
function PutBucketEvent (mac, config, options, bucket, callbackFunc) {
695+
function PutBucketEvent(mac, config, options, bucket, callbackFunc) {
695696
options = options || {};
696697
var reqParams = { // 必填参数
697698
bucket: bucket,
@@ -736,7 +737,7 @@ BucketManager.prototype.updateBucketEvent = function (bucket, options, callbackF
736737
UpdateBucketEvent(this.mac, this.config, options, bucket, callbackFunc);
737738
};
738739

739-
function UpdateBucketEvent (mac, config, options, bucket, callbackFunc) {
740+
function UpdateBucketEvent(mac, config, options, bucket, callbackFunc) {
740741
options = options || {};
741742
var reqParams = {
742743
bucket: bucket,
@@ -806,7 +807,7 @@ BucketManager.prototype.putReferAntiLeech = function (bucket, options, callbackF
806807
PutReferAntiLeech(this.mac, this.config, bucket, options, callbackFunc);
807808
};
808809

809-
function PutReferAntiLeech (mac, config, bucket, options, callbackFunc) {
810+
function PutReferAntiLeech(mac, config, bucket, options, callbackFunc) {
810811
options = options || {};
811812
var reqParams = {
812813
bucket: bucket
@@ -848,7 +849,7 @@ BucketManager.prototype.putCorsRules = function (bucket, body, callbackFunc) {
848849
PutCorsRules(this.mac, this.config, bucket, body, callbackFunc);
849850
};
850851

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

864-
function GetCorsRules (mac, config, bucket, callbackFunc) {
865+
function GetCorsRules(mac, config, bucket, callbackFunc) {
865866
var scheme = config.useHttpsDomain ? 'https://' : 'http://';
866867
var requestURI = scheme + conf.UC_HOST + '/corsRules/get/' + bucket;
867868
var digest = util.generateAccessToken(mac, requestURI, null);
@@ -976,14 +977,14 @@ BucketManager.prototype.listBucketDomains = function (bucket, callbackFunc) {
976977
//解冻归档存储文件
977978
BucketManager.prototype.restoreAr = function (entry, freezeAfterDays, callbackFunc) {
978979
var scheme = this.config.useHttpsDomain ? 'https://' : 'http://';
979-
var requestURI = scheme + conf.RS_QBOX + "/restoreAr/"+util.urlsafeBase64Encode(entry)+"/freezeAfterDays/"+freezeAfterDays;
980+
var requestURI = scheme + conf.RS_HOST + "/restoreAr/" + util.urlsafeBase64Encode(entry) + "/freezeAfterDays/" + freezeAfterDays;
980981
var digest = util.generateAccessToken(this.mac, requestURI, null);
981982
rpc.postWithoutForm(requestURI, digest, callbackFunc);
982983
};
983984

984985
// 上传策略
985986
// @link https://developer.qiniu.com/kodo/manual/1206/put-policy
986-
function PutPolicy (options) {
987+
function PutPolicy(options) {
987988
if (typeof options !== 'object') {
988989
throw new Error('invalid putpolicy options');
989990
}

0 commit comments

Comments
 (0)