-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cache): add versioning to content and index
Fixes: #50 This will allow us to do automated migrations in the future as the cache format changes. BREAKING CHANGE: index/content directories are now versioned. Previous caches are no longer compatible and cannot be migrated.
- Loading branch information
Showing
3 changed files
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
'use strict' | ||
|
||
var contentVer = require('../../package.json')['cache-version'].content | ||
var path = require('path') | ||
|
||
// Current format of content file path: | ||
// | ||
// ~/.my-cache/content-v1/sha512/ba/bada55deadbeefc0ffee | ||
// | ||
module.exports = contentPath | ||
function contentPath (cache, address, hashAlgorithm) { | ||
address = address && address.toLowerCase() | ||
hashAlgorithm = hashAlgorithm ? hashAlgorithm.toLowerCase() : 'sha512' | ||
return path.join( | ||
cache, 'content', hashAlgorithm, address.slice(0, 2), address) | ||
cache, | ||
`content-v${contentVer}`, | ||
hashAlgorithm, | ||
address.slice(0, 2), | ||
address | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters