cacache 10.0.2 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +2 -2
- package/get.js +22 -14
- package/lib/content/read.js +29 -14
- package/lib/content/write.js +3 -1
- package/lib/entry-index.js +14 -6
- package/lib/util/tmp.js +10 -2
- package/lib/verify.js +25 -12
- package/package.json +15 -15
- package/put.js +20 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="11.0.1"></a>
|
|
6
|
+
## [11.0.1](https://github.com/zkat/cacache/compare/v11.0.0...v11.0.1) (2018-04-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<a name="11.0.0"></a>
|
|
11
|
+
# [11.0.0](https://github.com/zkat/cacache/compare/v10.0.4...v11.0.0) (2018-04-09)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **opts:** use figgy-pudding for opts ([#128](https://github.com/zkat/cacache/issues/128)) ([33d4eed](https://github.com/zkat/cacache/commit/33d4eed))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### meta
|
|
20
|
+
|
|
21
|
+
* drop support for node@4 ([529f347](https://github.com/zkat/cacache/commit/529f347))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* node@4 is no longer supported
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<a name="10.0.4"></a>
|
|
31
|
+
## [10.0.4](https://github.com/zkat/cacache/compare/v10.0.3...v10.0.4) (2018-02-16)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<a name="10.0.3"></a>
|
|
36
|
+
## [10.0.3](https://github.com/zkat/cacache/compare/v10.0.2...v10.0.3) (2018-02-16)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **content:** rethrow aggregate errors as ENOENT ([fa918f5](https://github.com/zkat/cacache/commit/fa918f5))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
5
45
|
<a name="10.0.2"></a>
|
|
6
46
|
## [10.0.2](https://github.com/zkat/cacache/compare/v10.0.1...v10.0.2) (2018-01-07)
|
|
7
47
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ concurrency, and it will never give you corrupted data, even if cache files
|
|
|
6
6
|
get corrupted or manipulated.
|
|
7
7
|
|
|
8
8
|
It was originally written to be used as [npm](https://npm.im)'s local cache, but
|
|
9
|
-
can just as easily be used on its own
|
|
9
|
+
can just as easily be used on its own.
|
|
10
10
|
|
|
11
11
|
_Translations: [español](README.es.md)_
|
|
12
12
|
|
|
@@ -117,7 +117,7 @@ translations. To use the English API as documented in this README, use
|
|
|
117
117
|
`require('cacache')`, but may change in the future.
|
|
118
118
|
|
|
119
119
|
cacache also supports other languages! You can find the list of currently
|
|
120
|
-
supported ones
|
|
120
|
+
supported ones by looking in `./locales` in the source directory. You can use
|
|
121
121
|
the API in that language with `require('cacache/<lang>')`.
|
|
122
122
|
|
|
123
123
|
Want to add support for a new language? Please go ahead! You should be able to
|
package/get.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const BB = require('bluebird')
|
|
4
4
|
|
|
5
|
+
const figgyPudding = require('figgy-pudding')
|
|
5
6
|
const fs = require('fs')
|
|
6
7
|
const index = require('./lib/entry-index')
|
|
7
8
|
const memo = require('./lib/memoization')
|
|
@@ -10,6 +11,12 @@ const pipeline = require('mississippi').pipeline
|
|
|
10
11
|
const read = require('./lib/content/read')
|
|
11
12
|
const through = require('mississippi').through
|
|
12
13
|
|
|
14
|
+
const GetOpts = figgyPudding({
|
|
15
|
+
integrity: {},
|
|
16
|
+
memoize: {},
|
|
17
|
+
size: {}
|
|
18
|
+
})
|
|
19
|
+
|
|
13
20
|
module.exports = function get (cache, key, opts) {
|
|
14
21
|
return getData(false, cache, key, opts)
|
|
15
22
|
}
|
|
@@ -17,11 +24,11 @@ module.exports.byDigest = function getByDigest (cache, digest, opts) {
|
|
|
17
24
|
return getData(true, cache, digest, opts)
|
|
18
25
|
}
|
|
19
26
|
function getData (byDigest, cache, key, opts) {
|
|
20
|
-
opts = opts
|
|
27
|
+
opts = GetOpts(opts)
|
|
21
28
|
const memoized = (
|
|
22
29
|
byDigest
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
? memo.get.byDigest(cache, key, opts)
|
|
31
|
+
: memo.get(cache, key, opts)
|
|
25
32
|
)
|
|
26
33
|
if (memoized && opts.memoize !== false) {
|
|
27
34
|
return BB.resolve(byDigest ? memoized : {
|
|
@@ -58,7 +65,7 @@ function getData (byDigest, cache, key, opts) {
|
|
|
58
65
|
|
|
59
66
|
module.exports.stream = getStream
|
|
60
67
|
function getStream (cache, key, opts) {
|
|
61
|
-
opts = opts
|
|
68
|
+
opts = GetOpts(opts)
|
|
62
69
|
let stream = through()
|
|
63
70
|
const memoized = memo.get(cache, key, opts)
|
|
64
71
|
if (memoized && opts.memoize !== false) {
|
|
@@ -91,7 +98,6 @@ function getStream (cache, key, opts) {
|
|
|
91
98
|
} else {
|
|
92
99
|
memoStream = through()
|
|
93
100
|
}
|
|
94
|
-
opts.size = opts.size == null ? entry.size : opts.size
|
|
95
101
|
stream.emit('metadata', entry.metadata)
|
|
96
102
|
stream.emit('integrity', entry.integrity)
|
|
97
103
|
stream.emit('size', entry.size)
|
|
@@ -101,7 +107,9 @@ function getStream (cache, key, opts) {
|
|
|
101
107
|
ev === 'size' && cb(entry.size)
|
|
102
108
|
})
|
|
103
109
|
pipe(
|
|
104
|
-
read.readStream(cache, entry.integrity, opts
|
|
110
|
+
read.readStream(cache, entry.integrity, opts.concat({
|
|
111
|
+
size: opts.size == null ? entry.size : opts.size
|
|
112
|
+
})),
|
|
105
113
|
memoStream,
|
|
106
114
|
stream
|
|
107
115
|
)
|
|
@@ -111,7 +119,7 @@ function getStream (cache, key, opts) {
|
|
|
111
119
|
|
|
112
120
|
module.exports.stream.byDigest = getStreamDigest
|
|
113
121
|
function getStreamDigest (cache, integrity, opts) {
|
|
114
|
-
opts = opts
|
|
122
|
+
opts = GetOpts(opts)
|
|
115
123
|
const memoized = memo.get.byDigest(cache, integrity, opts)
|
|
116
124
|
if (memoized && opts.memoize !== false) {
|
|
117
125
|
const stream = through()
|
|
@@ -143,7 +151,7 @@ function getStreamDigest (cache, integrity, opts) {
|
|
|
143
151
|
|
|
144
152
|
module.exports.info = info
|
|
145
153
|
function info (cache, key, opts) {
|
|
146
|
-
opts = opts
|
|
154
|
+
opts = GetOpts(opts)
|
|
147
155
|
const memoized = memo.get(cache, key, opts)
|
|
148
156
|
if (memoized && opts.memoize !== false) {
|
|
149
157
|
return BB.resolve(memoized.entry)
|
|
@@ -161,7 +169,7 @@ module.exports.copy.byDigest = function cpDigest (cache, digest, dest, opts) {
|
|
|
161
169
|
return copy(true, cache, digest, dest, opts)
|
|
162
170
|
}
|
|
163
171
|
function copy (byDigest, cache, key, dest, opts) {
|
|
164
|
-
opts = opts
|
|
172
|
+
opts = GetOpts(opts)
|
|
165
173
|
if (read.copy) {
|
|
166
174
|
return (
|
|
167
175
|
byDigest ? BB.resolve(null) : index.find(cache, key, opts)
|
|
@@ -180,11 +188,11 @@ function copy (byDigest, cache, key, dest, opts) {
|
|
|
180
188
|
} else {
|
|
181
189
|
return getData(byDigest, cache, key, opts).then(res => {
|
|
182
190
|
return fs.writeFileAsync(dest, byDigest ? res : res.data)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
191
|
+
.then(() => byDigest ? key : {
|
|
192
|
+
metadata: res.metadata,
|
|
193
|
+
size: res.size,
|
|
194
|
+
integrity: res.integrity
|
|
195
|
+
})
|
|
188
196
|
})
|
|
189
197
|
}
|
|
190
198
|
}
|
package/lib/content/read.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const BB = require('bluebird')
|
|
4
4
|
|
|
5
5
|
const contentPath = require('./path')
|
|
6
|
+
const figgyPudding = require('figgy-pudding')
|
|
6
7
|
const fs = require('graceful-fs')
|
|
7
8
|
const PassThrough = require('stream').PassThrough
|
|
8
9
|
const pipe = BB.promisify(require('mississippi').pipe)
|
|
@@ -11,9 +12,13 @@ const Y = require('../util/y.js')
|
|
|
11
12
|
|
|
12
13
|
BB.promisifyAll(fs)
|
|
13
14
|
|
|
15
|
+
const ReadOpts = figgyPudding({
|
|
16
|
+
size: {}
|
|
17
|
+
})
|
|
18
|
+
|
|
14
19
|
module.exports = read
|
|
15
20
|
function read (cache, integrity, opts) {
|
|
16
|
-
opts = opts
|
|
21
|
+
opts = ReadOpts(opts)
|
|
17
22
|
return pickContentSri(cache, integrity).then(content => {
|
|
18
23
|
const sri = content.sri
|
|
19
24
|
const cpath = contentPath(cache, sri)
|
|
@@ -32,7 +37,7 @@ function read (cache, integrity, opts) {
|
|
|
32
37
|
module.exports.stream = readStream
|
|
33
38
|
module.exports.readStream = readStream
|
|
34
39
|
function readStream (cache, integrity, opts) {
|
|
35
|
-
opts = opts
|
|
40
|
+
opts = ReadOpts(opts)
|
|
36
41
|
const stream = new PassThrough()
|
|
37
42
|
pickContentSri(
|
|
38
43
|
cache, integrity
|
|
@@ -56,7 +61,7 @@ if (fs.copyFile) {
|
|
|
56
61
|
module.exports.copy = copy
|
|
57
62
|
}
|
|
58
63
|
function copy (cache, integrity, dest, opts) {
|
|
59
|
-
opts = opts
|
|
64
|
+
opts = ReadOpts(opts)
|
|
60
65
|
return pickContentSri(cache, integrity).then(content => {
|
|
61
66
|
const sri = content.sri
|
|
62
67
|
const cpath = contentPath(cache, sri)
|
|
@@ -68,17 +73,17 @@ module.exports.hasContent = hasContent
|
|
|
68
73
|
function hasContent (cache, integrity) {
|
|
69
74
|
if (!integrity) { return BB.resolve(false) }
|
|
70
75
|
return pickContentSri(cache, integrity)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
.catch({code: 'ENOENT'}, () => false)
|
|
77
|
+
.catch({code: 'EPERM'}, err => {
|
|
78
|
+
if (process.platform !== 'win32') {
|
|
79
|
+
throw err
|
|
80
|
+
} else {
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
}).then(content => {
|
|
84
|
+
if (!content.sri) return false
|
|
85
|
+
return ({ sri: content.sri, size: content.stat.size })
|
|
86
|
+
})
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
module.exports._pickContentSri = pickContentSri
|
|
@@ -95,6 +100,16 @@ function pickContentSri (cache, integrity) {
|
|
|
95
100
|
return BB.any(sri[sri.pickAlgorithm()].map(meta => {
|
|
96
101
|
return pickContentSri(cache, meta)
|
|
97
102
|
}))
|
|
103
|
+
.catch(err => {
|
|
104
|
+
if ([].some.call(err, e => e.code === 'ENOENT')) {
|
|
105
|
+
throw Object.assign(
|
|
106
|
+
new Error('No matching content found for ' + sri.toString()),
|
|
107
|
+
{code: 'ENOENT'}
|
|
108
|
+
)
|
|
109
|
+
} else {
|
|
110
|
+
throw err[0]
|
|
111
|
+
}
|
|
112
|
+
})
|
|
98
113
|
}
|
|
99
114
|
}
|
|
100
115
|
|
package/lib/content/write.js
CHANGED
|
@@ -28,7 +28,9 @@ function write (cache, data, opts) {
|
|
|
28
28
|
if (typeof opts.size === 'number' && data.length !== opts.size) {
|
|
29
29
|
return BB.reject(sizeError(opts.size, data.length))
|
|
30
30
|
}
|
|
31
|
-
const sri = ssri.fromData(data,
|
|
31
|
+
const sri = ssri.fromData(data, {
|
|
32
|
+
algorithms: opts.algorithms
|
|
33
|
+
})
|
|
32
34
|
if (opts.integrity && !ssri.checkData(data, opts.integrity, opts)) {
|
|
33
35
|
return BB.reject(checksumError(opts.integrity, sri))
|
|
34
36
|
}
|
package/lib/entry-index.js
CHANGED
|
@@ -4,6 +4,7 @@ const BB = require('bluebird')
|
|
|
4
4
|
|
|
5
5
|
const contentPath = require('./content/path')
|
|
6
6
|
const crypto = require('crypto')
|
|
7
|
+
const figgyPudding = require('figgy-pudding')
|
|
7
8
|
const fixOwner = require('./util/fix-owner')
|
|
8
9
|
const fs = require('graceful-fs')
|
|
9
10
|
const hashToSegments = require('./util/hash-to-segments')
|
|
@@ -29,9 +30,16 @@ module.exports.NotFoundError = class NotFoundError extends Error {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const IndexOpts = figgyPudding({
|
|
34
|
+
metadata: {},
|
|
35
|
+
size: {},
|
|
36
|
+
uid: {},
|
|
37
|
+
gid: {}
|
|
38
|
+
})
|
|
39
|
+
|
|
32
40
|
module.exports.insert = insert
|
|
33
41
|
function insert (cache, key, integrity, opts) {
|
|
34
|
-
opts = opts
|
|
42
|
+
opts = IndexOpts(opts)
|
|
35
43
|
const bucket = bucketPath(cache, key)
|
|
36
44
|
const entry = {
|
|
37
45
|
key,
|
|
@@ -197,9 +205,9 @@ function hashEntry (str) {
|
|
|
197
205
|
|
|
198
206
|
function hash (str, digest) {
|
|
199
207
|
return crypto
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
.createHash(digest)
|
|
209
|
+
.update(str)
|
|
210
|
+
.digest('hex')
|
|
203
211
|
}
|
|
204
212
|
|
|
205
213
|
function formatEntry (cache, entry) {
|
|
@@ -217,8 +225,8 @@ function formatEntry (cache, entry) {
|
|
|
217
225
|
|
|
218
226
|
function readdirOrEmpty (dir) {
|
|
219
227
|
return readdirAsync(dir)
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
.catch({code: 'ENOENT'}, () => [])
|
|
229
|
+
.catch({code: 'ENOTDIR'}, () => [])
|
|
222
230
|
}
|
|
223
231
|
|
|
224
232
|
function nop () {
|
package/lib/util/tmp.js
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
const BB = require('bluebird')
|
|
4
4
|
|
|
5
|
+
const figgyPudding = require('figgy-pudding')
|
|
5
6
|
const fixOwner = require('./fix-owner')
|
|
6
7
|
const path = require('path')
|
|
7
8
|
const rimraf = BB.promisify(require('rimraf'))
|
|
8
9
|
const uniqueFilename = require('unique-filename')
|
|
9
10
|
|
|
11
|
+
const TmpOpts = figgyPudding({
|
|
12
|
+
tmpPrefix: {},
|
|
13
|
+
uid: {},
|
|
14
|
+
gid: {}
|
|
15
|
+
})
|
|
16
|
+
|
|
10
17
|
module.exports.mkdir = mktmpdir
|
|
11
18
|
function mktmpdir (cache, opts) {
|
|
12
|
-
opts = opts
|
|
19
|
+
opts = TmpOpts(opts)
|
|
13
20
|
const tmpTarget = uniqueFilename(path.join(cache, 'tmp'), opts.tmpPrefix)
|
|
14
21
|
return fixOwner.mkdirfix(tmpTarget, opts.uid, opts.gid).then(() => {
|
|
15
22
|
return tmpTarget
|
|
@@ -22,11 +29,12 @@ function withTmp (cache, opts, cb) {
|
|
|
22
29
|
cb = opts
|
|
23
30
|
opts = null
|
|
24
31
|
}
|
|
25
|
-
opts = opts
|
|
32
|
+
opts = TmpOpts(opts)
|
|
26
33
|
return BB.using(mktmpdir(cache, opts).disposer(rimraf), cb)
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
module.exports.fix = fixtmpdir
|
|
30
37
|
function fixtmpdir (cache, opts) {
|
|
38
|
+
opts = TmpOpts(opts)
|
|
31
39
|
return fixOwner(path.join(cache, 'tmp'), opts.uid, opts.gid)
|
|
32
40
|
}
|
package/lib/verify.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const BB = require('bluebird')
|
|
4
4
|
|
|
5
5
|
const contentPath = require('./content/path')
|
|
6
|
+
const figgyPudding = require('figgy-pudding')
|
|
6
7
|
const finished = BB.promisify(require('mississippi').finished)
|
|
7
8
|
const fixOwner = require('./util/fix-owner')
|
|
8
9
|
const fs = require('graceful-fs')
|
|
@@ -14,10 +15,22 @@ const ssri = require('ssri')
|
|
|
14
15
|
|
|
15
16
|
BB.promisifyAll(fs)
|
|
16
17
|
|
|
18
|
+
const VerifyOpts = figgyPudding({
|
|
19
|
+
concurrency: {
|
|
20
|
+
default: 20
|
|
21
|
+
},
|
|
22
|
+
filter: {},
|
|
23
|
+
log: {
|
|
24
|
+
default: { silly () {} }
|
|
25
|
+
},
|
|
26
|
+
uid: {},
|
|
27
|
+
gid: {}
|
|
28
|
+
})
|
|
29
|
+
|
|
17
30
|
module.exports = verify
|
|
18
31
|
function verify (cache, opts) {
|
|
19
|
-
opts = opts
|
|
20
|
-
opts.log
|
|
32
|
+
opts = VerifyOpts(opts)
|
|
33
|
+
opts.log.silly('verify', 'verifying cache at', cache)
|
|
21
34
|
return BB.reduce([
|
|
22
35
|
markStartTime,
|
|
23
36
|
fixPerms,
|
|
@@ -40,7 +53,7 @@ function verify (cache, opts) {
|
|
|
40
53
|
})
|
|
41
54
|
}, {}).tap(stats => {
|
|
42
55
|
stats.runTime.total = stats.endTime - stats.startTime
|
|
43
|
-
opts.log
|
|
56
|
+
opts.log.silly('verify', 'verification finished for', cache, 'in', `${stats.runTime.total}ms`)
|
|
44
57
|
})
|
|
45
58
|
}
|
|
46
59
|
|
|
@@ -53,7 +66,7 @@ function markEndTime (cache, opts) {
|
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
function fixPerms (cache, opts) {
|
|
56
|
-
opts.log
|
|
69
|
+
opts.log.silly('verify', 'fixing cache permissions')
|
|
57
70
|
return fixOwner.mkdirfix(cache, opts.uid, opts.gid).then(() => {
|
|
58
71
|
// TODO - fix file permissions too
|
|
59
72
|
return fixOwner.chownr(cache, opts.uid, opts.gid)
|
|
@@ -70,11 +83,11 @@ function fixPerms (cache, opts) {
|
|
|
70
83
|
// 5. If content is not marked as live, rimraf it.
|
|
71
84
|
//
|
|
72
85
|
function garbageCollect (cache, opts) {
|
|
73
|
-
opts.log
|
|
86
|
+
opts.log.silly('verify', 'garbage collecting content')
|
|
74
87
|
const indexStream = index.lsStream(cache)
|
|
75
88
|
const liveContent = new Set()
|
|
76
89
|
indexStream.on('data', entry => {
|
|
77
|
-
if (opts
|
|
90
|
+
if (opts.filter && !opts.filter(entry)) { return }
|
|
78
91
|
liveContent.add(entry.integrity.toString())
|
|
79
92
|
})
|
|
80
93
|
return finished(indexStream).then(() => {
|
|
@@ -117,7 +130,7 @@ function garbageCollect (cache, opts) {
|
|
|
117
130
|
})
|
|
118
131
|
})
|
|
119
132
|
}
|
|
120
|
-
}, {concurrency: opts.concurrency
|
|
133
|
+
}, {concurrency: opts.concurrency}))
|
|
121
134
|
})
|
|
122
135
|
})
|
|
123
136
|
}
|
|
@@ -141,7 +154,7 @@ function verifyContent (filepath, sri) {
|
|
|
141
154
|
}
|
|
142
155
|
|
|
143
156
|
function rebuildIndex (cache, opts) {
|
|
144
|
-
opts.log
|
|
157
|
+
opts.log.silly('verify', 'rebuilding index')
|
|
145
158
|
return index.ls(cache).then(entries => {
|
|
146
159
|
const stats = {
|
|
147
160
|
missingContent: 0,
|
|
@@ -153,7 +166,7 @@ function rebuildIndex (cache, opts) {
|
|
|
153
166
|
if (entries.hasOwnProperty(k)) {
|
|
154
167
|
const hashed = index._hashKey(k)
|
|
155
168
|
const entry = entries[k]
|
|
156
|
-
const excluded = opts
|
|
169
|
+
const excluded = opts.filter && !opts.filter(entry)
|
|
157
170
|
excluded && stats.rejectedEntries++
|
|
158
171
|
if (buckets[hashed] && !excluded) {
|
|
159
172
|
buckets[hashed].push(entry)
|
|
@@ -170,7 +183,7 @@ function rebuildIndex (cache, opts) {
|
|
|
170
183
|
}
|
|
171
184
|
return BB.map(Object.keys(buckets), key => {
|
|
172
185
|
return rebuildBucket(cache, buckets[key], stats, opts)
|
|
173
|
-
}, {concurrency: opts.concurrency
|
|
186
|
+
}, {concurrency: opts.concurrency}).then(() => stats)
|
|
174
187
|
})
|
|
175
188
|
}
|
|
176
189
|
|
|
@@ -195,13 +208,13 @@ function rebuildBucket (cache, bucket, stats, opts) {
|
|
|
195
208
|
}
|
|
196
209
|
|
|
197
210
|
function cleanTmp (cache, opts) {
|
|
198
|
-
opts.log
|
|
211
|
+
opts.log.silly('verify', 'cleaning tmp directory')
|
|
199
212
|
return rimraf(path.join(cache, 'tmp'))
|
|
200
213
|
}
|
|
201
214
|
|
|
202
215
|
function writeVerifile (cache, opts) {
|
|
203
216
|
const verifile = path.join(cache, '_lastverified')
|
|
204
|
-
opts.log
|
|
217
|
+
opts.log.silly('verify', 'writing verifile to ' + verifile)
|
|
205
218
|
return fs.writeFileAsync(verifile, '' + (+(new Date())))
|
|
206
219
|
}
|
|
207
220
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacache",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"content": "2",
|
|
6
6
|
"index": "5"
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"benchmarks": "node test/benchmarks",
|
|
17
17
|
"prerelease": "npm t",
|
|
18
18
|
"postrelease": "npm publish && git push --follow-tags",
|
|
19
|
-
"pretest": "standard
|
|
19
|
+
"pretest": "standard",
|
|
20
20
|
"release": "standard-version -s",
|
|
21
|
-
"test": "cross-env CACACHE_UPDATE_LOCALE_FILES=true
|
|
21
|
+
"test": "cross-env CACACHE_UPDATE_LOCALE_FILES=true tap --coverage --nyc-arg=--all -J test/*.js",
|
|
22
22
|
"test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",
|
|
23
23
|
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
|
|
24
24
|
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'"
|
|
@@ -58,31 +58,31 @@
|
|
|
58
58
|
],
|
|
59
59
|
"license": "ISC",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"bluebird": "^3.5.
|
|
61
|
+
"bluebird": "^3.5.1",
|
|
62
62
|
"chownr": "^1.0.1",
|
|
63
|
+
"figgy-pudding": "^3.1.0",
|
|
63
64
|
"glob": "^7.1.2",
|
|
64
65
|
"graceful-fs": "^4.1.11",
|
|
65
|
-
"lru-cache": "^4.1.
|
|
66
|
-
"mississippi": "^
|
|
66
|
+
"lru-cache": "^4.1.2",
|
|
67
|
+
"mississippi": "^3.0.0",
|
|
67
68
|
"mkdirp": "^0.5.1",
|
|
68
69
|
"move-concurrently": "^1.0.1",
|
|
69
70
|
"promise-inflight": "^1.0.1",
|
|
70
|
-
"rimraf": "^2.6.
|
|
71
|
-
"ssri": "^
|
|
71
|
+
"rimraf": "^2.6.2",
|
|
72
|
+
"ssri": "^6.0.0",
|
|
72
73
|
"unique-filename": "^1.1.0",
|
|
73
|
-
"y18n": "^
|
|
74
|
+
"y18n": "^4.0.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"benchmark": "^2.1.4",
|
|
77
|
-
"chalk": "^2.
|
|
78
|
-
"cross-env": "^5.
|
|
79
|
-
"nyc": "^11.1.0",
|
|
78
|
+
"chalk": "^2.3.2",
|
|
79
|
+
"cross-env": "^5.1.4",
|
|
80
80
|
"require-inject": "^1.4.2",
|
|
81
81
|
"safe-buffer": "^5.1.1",
|
|
82
|
-
"standard": "^
|
|
83
|
-
"standard-version": "^4.
|
|
82
|
+
"standard": "^11.0.1",
|
|
83
|
+
"standard-version": "^4.3.0",
|
|
84
84
|
"tacks": "^1.2.2",
|
|
85
|
-
"tap": "^
|
|
85
|
+
"tap": "^11.1.3",
|
|
86
86
|
"weallbehave": "^1.2.0",
|
|
87
87
|
"weallcontribute": "^1.0.8"
|
|
88
88
|
},
|
package/put.js
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const figgyPudding = require('figgy-pudding')
|
|
3
4
|
const index = require('./lib/entry-index')
|
|
4
5
|
const memo = require('./lib/memoization')
|
|
5
6
|
const write = require('./lib/content/write')
|
|
6
7
|
const to = require('mississippi').to
|
|
7
8
|
|
|
9
|
+
const PutOpts = figgyPudding({
|
|
10
|
+
algorithms: {
|
|
11
|
+
default: ['sha512']
|
|
12
|
+
},
|
|
13
|
+
integrity: {},
|
|
14
|
+
memoize: {},
|
|
15
|
+
metadata: {},
|
|
16
|
+
size: {},
|
|
17
|
+
tmpPrefix: {},
|
|
18
|
+
uid: {},
|
|
19
|
+
gid: {}
|
|
20
|
+
})
|
|
21
|
+
|
|
8
22
|
module.exports = putData
|
|
9
23
|
function putData (cache, key, data, opts) {
|
|
10
|
-
opts = opts
|
|
24
|
+
opts = PutOpts(opts)
|
|
11
25
|
return write(cache, data, opts).then(res => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
26
|
+
return index.insert(
|
|
27
|
+
cache, key, res.integrity, opts.concat({size: res.size})
|
|
28
|
+
).then(entry => {
|
|
15
29
|
if (opts.memoize) {
|
|
16
30
|
memo.put(cache, entry, data, opts)
|
|
17
31
|
}
|
|
@@ -22,7 +36,7 @@ function putData (cache, key, data, opts) {
|
|
|
22
36
|
|
|
23
37
|
module.exports.stream = putStream
|
|
24
38
|
function putStream (cache, key, opts) {
|
|
25
|
-
opts = opts
|
|
39
|
+
opts = PutOpts(opts)
|
|
26
40
|
let integrity
|
|
27
41
|
let size
|
|
28
42
|
const contentStream = write.stream(
|
|
@@ -45,9 +59,7 @@ function putStream (cache, key, opts) {
|
|
|
45
59
|
})
|
|
46
60
|
}, cb => {
|
|
47
61
|
contentStream.end(() => {
|
|
48
|
-
|
|
49
|
-
opts.size = size
|
|
50
|
-
index.insert(cache, key, integrity, opts).then(entry => {
|
|
62
|
+
index.insert(cache, key, integrity, opts.concat({size})).then(entry => {
|
|
51
63
|
if (opts.memoize) {
|
|
52
64
|
memo.put(cache, entry, Buffer.concat(memoData, memoTotal), opts)
|
|
53
65
|
}
|