Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
add shasum when nfs.upload and hfs.uploadBuffer, fixed #148
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Jan 13, 2014
1 parent 40301f2 commit d463b09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 12 additions & 4 deletions controllers/registry/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,13 @@ exports.upload = function (req, res, next) {
});
}
shasum = shasum.digest('hex');
var key = common.getCDNKey(name, filename);
nfs.upload(filepath, {key: key, size: length}, function (err, result) {

var options = {
key: common.getCDNKey(name, filename),
size: length,
shasum: shasum
};
nfs.upload(filepath, options, function (err, result) {
// remove tmp file whatever
fs.unlink(filepath, utility.noop);
if (err) {
Expand Down Expand Up @@ -518,9 +523,12 @@ exports.addPackageAndDist = function (req, res, next) {
shasum = crypto.createHash('sha1');
shasum.update(tarballBuffer);
shasum = shasum.digest('hex');
var key = common.getCDNKey(name, filename);

nfs.uploadBuffer(tarballBuffer, {key: key}, ep.done('upload'));
var options = {
key: common.getCDNKey(name, filename),
shasum: shasum
};
nfs.uploadBuffer(tarballBuffer, options, ep.done('upload'));
});

ep.on('upload', function (result) {
Expand Down
8 changes: 6 additions & 2 deletions proxy/sync_module_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,12 @@ SyncModuleWorker.prototype._syncOneVersion = function (versionIndex, sourcePacka
return ep.emit('error', err);
}

var key = common.getCDNKey(sourcePackage.name, filename);
nfs.upload(filepath, {key: key, size: dataSize}, ep.done('uploadResult'));
var options = {
key: common.getCDNKey(sourcePackage.name, filename),
size: dataSize,
shasum: shasum
};
nfs.upload(filepath, options, ep.done('uploadResult'));
});
}));

Expand Down

0 comments on commit d463b09

Please sign in to comment.