How to use the cacache/lib/content/path.js function in cacache

To help you get started, we’ve selected a few cacache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github npm / tink / lib / pkgmap.js View on Github external
})
  }
  if (!cache || !hash) {
    throw new Error('stat() requires a fully-resolved pkgmap file address')
  }
  let info
  try {
    info = await ccRead.hasContent(cache, hash)
  } catch (err) {
    await repairPackage(cache, hash, pkg)
    info = await ccRead.hasContent(cache, hash)
  }
  if (!info) {
    return false
  }
  const cpath = ccPath(cache, info.sri)
  if (verify) {
    try {
      await ssri.checkStream(
        fs.createReadStream(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
      cache = newResolved.cache
      hash = newResolved.hash
      pkg = newResolved.pkg
      await ssri.checkStream(
        fs.createReadStream(cpath),
        info.sri
      )
    }
github npm / tink / lib / pkglock.js View on Github external
ssri.checkData(
        fs.readFileSync.orig(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = fetchPackageSync(cache, pkg, hash)
      cache = newResolved.cache
      ssri.checkData(
        fs.readFileSync.orig(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {
    integrity: info.sri.toString(),
    cachePath: ccPath(cache, info.sri)
  })
}
github npm / tink / lib / pkglock.js View on Github external
})
  }
  if (!cache || !hash) {
    throw new Error('statSync() requires a fully-resolved pkgmap file address')
  }
  let info
  try {
    info = ccGet.hasContent.sync(cache, hash, { memoize: true })
  } catch (err) {
    fetchPackageSync(cache, pkg, hash)
    info = ccGet.hasContent.sync(cache, hash, { memoize: true })
  }
  if (!info) {
    return false
  }
  const cpath = ccPath(cache, info.sri)
  if (verify) {
    try {
      ssri.checkData(
        fs.readFileSync.orig(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = fetchPackageSync(cache, pkg, hash)
      cache = newResolved.cache
      ssri.checkData(
        fs.readFileSync.orig(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {
github npm / tink / lib / pkglock.js View on Github external
await ssri.checkStream(
        fs.createReadStream.orig(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = await fetchPackage(cache, pkg, hash)
      cache = newResolved.cache
      await ssri.checkStream(
        fs.createReadStream.orig(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {
    integrity: info.sri.toString(),
    cachePath: ccPath(cache, info.sri)
  })
}
github npm / tink / lib / pkgmap.js View on Github external
info.sri
      )
    } catch (err) {
      const newResolved = repairPackageSync({ cache, hash, pkg, resolvedPath })
      cache = newResolved.cache
      hash = newResolved.hash
      pkg = newResolved.pkg
      ssri.checkData(
        fs.readFileSync(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {
    integrity: info.sri.toString(),
    cachePath: ccPath(cache, info.sri)
  })
}
github npm / tink / lib / pkgmap.js View on Github external
info.sri
      )
    } catch (err) {
      const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
      cache = newResolved.cache
      hash = newResolved.hash
      pkg = newResolved.pkg
      await ssri.checkStream(
        fs.createReadStream(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {
    integrity: info.sri.toString(),
    cachePath: ccPath(cache, info.sri)
  })
}
github npm / tink / lib / pkgmap.js View on Github external
})
  }
  if (!cache || !hash) {
    throw new Error('statSync() requires a fully-resolved pkgmap file address')
  }
  let info
  try {
    info = ccRead.hasContent.sync(cache, hash)
  } catch (err) {
    repairPackageSync(cache, hash, pkg)
    info = ccRead.hasContent.sync(cache, hash)
  }
  if (!info) {
    return false
  }
  const cpath = ccPath(cache, info.sri)
  if (verify) {
    try {
      ssri.checkData(
        fs.readFileSync(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = repairPackageSync({ cache, hash, pkg, resolvedPath })
      cache = newResolved.cache
      hash = newResolved.hash
      pkg = newResolved.pkg
      ssri.checkData(
        fs.readFileSync(cpath),
        info.sri
      )
    }
github npm / tink / lib / pkglock.js View on Github external
})
  }
  if (!cache || !hash) {
    throw new Error('stat() requires a fully-resolved pkgmap file address')
  }
  let info
  try {
    info = await ccGet.hasContent(cache, hash)
  } catch (err) {
    await fetchPackage(cache, hash, pkg)
    info = await ccGet.hasContent(cache, hash)
  }
  if (!info) {
    return false
  }
  const cpath = ccPath(cache, info.sri)
  if (verify) {
    try {
      await ssri.checkStream(
        fs.createReadStream.orig(cpath),
        info.sri
      )
    } catch (err) {
      const newResolved = await fetchPackage(cache, pkg, hash)
      cache = newResolved.cache
      await ssri.checkStream(
        fs.createReadStream.orig(cpath),
        info.sri
      )
    }
  }
  return Object.assign(info.stat, {