Skip to content

Commit

Permalink
fix(deps): bump cacache and use its size feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 23, 2017
1 parent e8c5a8c commit 926c1d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const cacache = require('cacache')
const fetch = require('node-fetch')
const fs = require('fs')
const pipe = require('mississippi').pipe
const ssri = require('ssri')
const through = require('mississippi').through
Expand Down Expand Up @@ -57,15 +56,7 @@ module.exports = class Cache {
status: 200
})
}
return new this.Promise((resolve, reject) => {
fs.stat(info.path, (err, stat) => {
if (err) {
return reject(err)
} else {
return resolve(stat)
}
})
}).then(stat => {
return Promise.resolve().then(() => {
const cachePath = this._path
let disturbed = false
// avoid opening cache file handles until a user actually tries to
Expand All @@ -75,7 +66,7 @@ module.exports = class Cache {
cb(null, chunk, enc)
} else {
disturbed = true
if (stat.size > MAX_MEM_SIZE) {
if (info.size > MAX_MEM_SIZE) {
pipe(
cacache.get.stream.byDigest(cachePath, info.integrity),
body,
Expand All @@ -99,7 +90,7 @@ module.exports = class Cache {
url: req.url,
headers: resHeaders,
status: 200,
size: stat.size
size: info.size
})
}).catch(err => {
if (err.code === 'ENOENT') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
"dependencies": {
"agentkeepalive": "^3.1.0",
"cacache": "^7.0.5",
"cacache": "^8.0.0",
"http-cache-semantics": "^3.7.3",
"http-proxy-agent": "^1.0.0",
"https-proxy-agent": "^1.0.0",
Expand Down

0 comments on commit 926c1d3

Please sign in to comment.