source: trip-planner-front/node_modules/cacache/lib/content/path.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 737 bytes
Line 
1'use strict'
2
3const contentVer = require('../../package.json')['cache-version'].content
4const hashToSegments = require('../util/hash-to-segments')
5const path = require('path')
6const ssri = require('ssri')
7
8// Current format of content file path:
9//
10// sha512-BaSE64Hex= ->
11// ~/.my-cache/content-v2/sha512/ba/da/55deadbeefc0ffee
12//
13module.exports = contentPath
14
15function contentPath (cache, integrity) {
16 const sri = ssri.parse(integrity, { single: true })
17 // contentPath is the *strongest* algo given
18 return path.join(
19 contentDir(cache),
20 sri.algorithm,
21 ...hashToSegments(sri.hexDigest())
22 )
23}
24
25module.exports.contentDir = contentDir
26
27function contentDir (cache) {
28 return path.join(cache, `content-v${contentVer}`)
29}
Note: See TracBrowser for help on using the repository browser.