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

Commit

Permalink
fix(cache): reduce race condition window by checking for content
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed May 4, 2017
1 parent 66bba4b commit 24544b1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ module.exports = class Cache {
opts = opts || {}
const key = cacheKey(req)
return cacache.get.info(this._path, key).then(info => {
return info && cacache.get.hasContent(
this._path, info.integrity, opts
).then(exists => exists && info)
}).then(info => {
if (info && info.metadata && matchDetails(req, {
url: info.metadata.url,
reqHeaders: new fetch.Headers(info.metadata.reqHeaders),
Expand Down

0 comments on commit 24544b1

Please sign in to comment.