Skip to content

Commit

Permalink
Merge pull request #38 from Rich-Harris/feat-hash-ppackage-path-on-disk
Browse files Browse the repository at this point in the history
sha1 for hash on disk
  • Loading branch information
Sven SAULEAU authored Dec 26, 2017
2 parents 96ec6a5 + 5ea018e commit b4bff42
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"sander": "^0.6.0",
"semver": "^5.3.0",
"serve-favicon": "^2.4.2",
"sha1": "^1.1.1",
"tar": "^3.2.1",
"uglify-js": "^3.0.25"
},
Expand Down
3 changes: 3 additions & 0 deletions server/serve-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const findVersion = require( './utils/findVersion.js' );
const logger = require( './logger.js' );
const cache = require( './cache.js' );
const etag = require('etag');
const sha1 = require('sha1');

const { root, registry, additionalBundleResHeaders } = require( '../config.js' );

Expand Down Expand Up @@ -108,6 +109,8 @@ function fetchBundle ( pkg, version, deep, query ) {

logger.info( `[${pkg.name}] requested package` );

hash = sha1(hash);

if ( cache.has( hash ) ) {
logger.info( `[${pkg.name}] is cached` );
return Promise.resolve( cache.get( hash ) );
Expand Down

0 comments on commit b4bff42

Please sign in to comment.