Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
685af2a367 | ||
|
|
818f216fb4 | ||
|
|
1b47495565 | ||
|
|
0ab314f27c | ||
|
|
95076c8787 | ||
|
|
4e6eb0a9cc | ||
|
|
29f17dd5d1 | ||
|
|
3a48637ef1 | ||
|
|
e1029b005f | ||
|
|
66771dfc3b | ||
|
|
66f05a2f07 | ||
|
|
6660cabbb6 | ||
|
|
fbe1971957 |
16
History.md
16
History.md
@@ -1,4 +1,20 @@
|
||||
|
||||
0.3.3 / 2014-02-28
|
||||
==================
|
||||
|
||||
* Merge pull request #232 from cnpm/host-hotfix
|
||||
* get request host from request.headers
|
||||
* Merge pull request #231 from cnpm/bug-fix
|
||||
* fix deps display bug#230 and nsf.url TypeError#229
|
||||
|
||||
0.3.2 / 2014-02-28
|
||||
==================
|
||||
|
||||
* update koa-sess and koa-redis
|
||||
* fix sync all test
|
||||
* remove nfs.downloadStream first, fix tmppath error
|
||||
* fix fengmk2/giturl#1 bug
|
||||
|
||||
0.3.1 / 2014-02-27
|
||||
==================
|
||||
|
||||
|
||||
@@ -182,10 +182,14 @@ exports.download = function *(next) {
|
||||
var version = filename.slice(name.length + 1, -4);
|
||||
var row = yield Module.get(name, version);
|
||||
// can not get dist
|
||||
var url = nfs.url(common.getCDNKey(name, filename));
|
||||
var url = null;
|
||||
|
||||
if (typeof nfs.url === 'function') {
|
||||
url = nfs.url(common.getCDNKey(name, filename));
|
||||
}
|
||||
|
||||
if (!row || !row.package || !row.package.dist) {
|
||||
if (!nfs.url) {
|
||||
if (!url) {
|
||||
return yield next;
|
||||
}
|
||||
this.status = 302;
|
||||
@@ -193,6 +197,7 @@ exports.download = function *(next) {
|
||||
_downloads[name] = (_downloads[name] || 0) + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
var dist = row.package.dist;
|
||||
if (!dist.key) {
|
||||
debug('get tarball by 302');
|
||||
@@ -203,7 +208,7 @@ exports.download = function *(next) {
|
||||
}
|
||||
|
||||
// else use `dist.key` to get tarball from nfs
|
||||
if (!nfs.downloadStream && !nfs.download) {
|
||||
if (!nfs.download) {
|
||||
return yield next;
|
||||
}
|
||||
|
||||
@@ -216,13 +221,9 @@ exports.download = function *(next) {
|
||||
this.set('Content-Disposition', 'attachment; filename="' + filename + '"');
|
||||
this.set('ETag', dist.shasum);
|
||||
|
||||
if (nfs.downloadStream) {
|
||||
yield nfs.downloadStream(dist.key, this.res, {timeout: DOWNLOAD_TIMEOUT});
|
||||
return;
|
||||
}
|
||||
|
||||
// use download file api
|
||||
var tmpPath = path.join(config.uploadDir, utility.randomString() + dist.key);
|
||||
var tmpPath = path.join(config.uploadDir,
|
||||
utility.randomString() + dist.key.replace(/\//g, '-'));
|
||||
function cleanup() {
|
||||
fs.unlink(tmpPath, utility.noop);
|
||||
}
|
||||
@@ -233,8 +234,8 @@ exports.download = function *(next) {
|
||||
this.throw(err);
|
||||
}
|
||||
var tarball = fs.createReadStream(tmpPath);
|
||||
tarball.on('error', cleanup);
|
||||
tarball.on('end', cleanup);
|
||||
tarball.once('error', cleanup);
|
||||
tarball.once('end', cleanup);
|
||||
this.body = tarball;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ exports.display = function *(next) {
|
||||
];
|
||||
var pkg = r[0];
|
||||
var download = r[1];
|
||||
var dependents = r[2];
|
||||
var dependents = (r[2] || []).map(function (item) {
|
||||
return item.deps;
|
||||
});
|
||||
|
||||
if (!pkg || !pkg.package) {
|
||||
return yield next;
|
||||
@@ -90,7 +92,7 @@ exports.display = function *(next) {
|
||||
}
|
||||
|
||||
if (pkg.repository && pkg.repository.url) {
|
||||
pkg.repository.weburl = giturl.parse(pkg.repository.url);
|
||||
pkg.repository.weburl = giturl.parse(pkg.repository.url) || pkg.repository.url;
|
||||
}
|
||||
|
||||
setLicense(pkg);
|
||||
|
||||
@@ -31,7 +31,7 @@ exports.getCDNKey = function (name, filename) {
|
||||
|
||||
exports.setDownloadURL = function (pkg, ctx, host) {
|
||||
if (pkg.dist) {
|
||||
host = host || ctx.host;
|
||||
host = host || ctx.get('host') || ctx.host;
|
||||
pkg.dist.tarball = util.format('%s://%s/%s/download/%s-%s.tgz',
|
||||
ctx.protocol,
|
||||
host, pkg.name, pkg.name, pkg.version);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cnpmjs.org",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.3",
|
||||
"description": "Private npm registry and web for Enterprise, base on MySQL and Simple Store Service",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -21,15 +21,15 @@
|
||||
"co-read": "0.0.1",
|
||||
"co-write": "0.3.0",
|
||||
"debug": "0.7.4",
|
||||
"eventproxy": "0.2.6",
|
||||
"eventproxy": "0.2.7",
|
||||
"forward": "0.0.4",
|
||||
"giturl": "0.0.1",
|
||||
"giturl": "0.0.2",
|
||||
"graceful": "0.0.6",
|
||||
"gravatar": "1.0.6",
|
||||
"humanize-number": "0.0.2",
|
||||
"koa": "0.5.0",
|
||||
"koa-markdown": "0.0.2",
|
||||
"koa-middlewares": "0.0.5",
|
||||
"koa-middlewares": "0.0.6",
|
||||
"logfilestream": "0.1.0",
|
||||
"marked": "0.3.1",
|
||||
"microtime": "0.5.1",
|
||||
|
||||
@@ -537,34 +537,6 @@ describe('controllers/registry/module.test.js', function () {
|
||||
.expect('Location', 'http://qtestbucket.qiniudn.com/cutter/-/cutter-0.0.2.tgz')
|
||||
.expect(302, done)
|
||||
});
|
||||
|
||||
it('should download a file direct from nfs stream', function (done) {
|
||||
var nfs = require('../../../common/nfs');
|
||||
mm(nfs, 'downloadStream', thunkify(function (key, writeStream, options, callback) {
|
||||
options.timeout.should.equal(600000);
|
||||
nfs._client.download(key, {writeStream: writeStream, timeout: options.timeout}, callback);
|
||||
}));
|
||||
Module.__get__ = Module.get;
|
||||
mm(Module, 'get', thunkify(function (name, version, callback) {
|
||||
Module.__get__(name, version, function (err, info) {
|
||||
info.package.dist.key = 'cutter/-/cutter-0.0.2.tgz';
|
||||
callback(err, info);
|
||||
});
|
||||
}));
|
||||
request(app)
|
||||
.get('/cutter/download/cutter-0.0.2.tgz')
|
||||
.expect('ETag', 'c61fde5e8c26d053574d0c722097029fd1bc963a')
|
||||
.expect('Content-Type', 'application/octet-stream')
|
||||
.expect('Content-Length', '3139')
|
||||
.expect('Content-Disposition', 'attachment; filename="cutter-0.0.2.tgz"')
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
should.not.exist(err);
|
||||
// TODO: why supertest change buffer to text?
|
||||
// res.text.length.should.equal(3139);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('DELETE /:name/download/:filename/-rev/:rev', function () {
|
||||
|
||||
@@ -50,7 +50,7 @@ describe('sync/sync_all.js', function () {
|
||||
mm.data(Module, 'listAllModuleNames', [{name: 'cnpmjs.org'}, {name: 'cutter'}]);
|
||||
sync(function (err, data) {
|
||||
should.not.exist(err);
|
||||
data.successes.should.eql(['cnpm', 'cnpmjs.org', 'cutter']);
|
||||
data.successes.should.eql(['cnpmjs.org', 'cutter']);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user