cacache 11.2.0 → 11.3.3
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 +44 -1
- package/README.es.md +1 -1
- package/README.md +1 -1
- package/get.js +50 -1
- package/lib/content/path.js +1 -1
- package/lib/content/read.js +6 -6
- package/lib/content/write.js +4 -4
- package/lib/entry-index.js +86 -29
- package/lib/util/fix-owner.js +48 -2
- package/lib/verify.js +4 -4
- package/locales/en.js +3 -0
- package/locales/en.json +3 -2
- package/locales/es.js +3 -0
- package/package.json +17 -17
- package/put.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
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
|
+
### [11.3.3](https://github.com/zkat/cacache/compare/v11.3.2...v11.3.3) (2019-06-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **audit:** npm audit fix ([200a6d5](https://github.com/zkat/cacache/commit/200a6d5))
|
|
11
|
+
* **config:** Add ssri config 'error' option ([#146](https://github.com/zkat/cacache/issues/146)) ([47de8f5](https://github.com/zkat/cacache/commit/47de8f5))
|
|
12
|
+
* **deps:** npm audit fix ([481a7dc](https://github.com/zkat/cacache/commit/481a7dc))
|
|
13
|
+
* **standard:** standard --fix ([7799149](https://github.com/zkat/cacache/commit/7799149))
|
|
14
|
+
* **write:** avoid another cb never called situation ([5156561](https://github.com/zkat/cacache/commit/5156561))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
<a name="11.3.2"></a>
|
|
19
|
+
## [11.3.2](https://github.com/zkat/cacache/compare/v11.3.1...v11.3.2) (2018-12-21)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **get:** make sure to handle errors in the .then ([b10bcd0](https://github.com/zkat/cacache/commit/b10bcd0))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<a name="11.3.1"></a>
|
|
29
|
+
## [11.3.1](https://github.com/zkat/cacache/compare/v11.3.0...v11.3.1) (2018-11-05)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* **get:** export hasContent.sync properly ([d76c920](https://github.com/zkat/cacache/commit/d76c920))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
<a name="11.3.0"></a>
|
|
39
|
+
# [11.3.0](https://github.com/zkat/cacache/compare/v11.2.0...v11.3.0) (2018-11-05)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* **get:** add sync API for reading ([db1e094](https://github.com/zkat/cacache/commit/db1e094))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
5
48
|
<a name="11.2.0"></a>
|
|
6
49
|
# [11.2.0](https://github.com/zkat/cacache/compare/v11.1.0...v11.2.0) (2018-08-08)
|
|
7
50
|
|
package/README.es.md
CHANGED
|
@@ -287,7 +287,7 @@ entrada si existe.
|
|
|
287
287
|
|
|
288
288
|
* `key` - Clave de la entrada. Igual al argumento `clave`.
|
|
289
289
|
* `integrity` - [hacheo de Subresource Integrity](#integrity) del contenido al que se refiere esta entrada.
|
|
290
|
-
* `path` - Dirección del fichero de datos almacenados,
|
|
290
|
+
* `path` - Dirección del fichero de datos almacenados, unida al argumento `cache`.
|
|
291
291
|
* `time` - Hora de creación de la entrada
|
|
292
292
|
* `metadata` - Metadatos asignados a esta entrada por el usuario
|
|
293
293
|
|
package/README.md
CHANGED
|
@@ -290,7 +290,7 @@ one exists.
|
|
|
290
290
|
|
|
291
291
|
* `key` - Key the entry was looked up under. Matches the `key` argument.
|
|
292
292
|
* `integrity` - [Subresource Integrity hash](#integrity) for the content this entry refers to.
|
|
293
|
-
* `path` - Filesystem path
|
|
293
|
+
* `path` - Filesystem path where content is stored, joined with `cache` argument.
|
|
294
294
|
* `time` - Timestamp the entry was first added on.
|
|
295
295
|
* `metadata` - User-assigned metadata associated with the entry/content.
|
|
296
296
|
|
package/get.js
CHANGED
|
@@ -63,6 +63,55 @@ function getData (byDigest, cache, key, opts) {
|
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
module.exports.sync = function get (cache, key, opts) {
|
|
67
|
+
return getDataSync(false, cache, key, opts)
|
|
68
|
+
}
|
|
69
|
+
module.exports.sync.byDigest = function getByDigest (cache, digest, opts) {
|
|
70
|
+
return getDataSync(true, cache, digest, opts)
|
|
71
|
+
}
|
|
72
|
+
function getDataSync (byDigest, cache, key, opts) {
|
|
73
|
+
opts = GetOpts(opts)
|
|
74
|
+
const memoized = (
|
|
75
|
+
byDigest
|
|
76
|
+
? memo.get.byDigest(cache, key, opts)
|
|
77
|
+
: memo.get(cache, key, opts)
|
|
78
|
+
)
|
|
79
|
+
if (memoized && opts.memoize !== false) {
|
|
80
|
+
return byDigest ? memoized : {
|
|
81
|
+
metadata: memoized.entry.metadata,
|
|
82
|
+
data: memoized.data,
|
|
83
|
+
integrity: memoized.entry.integrity,
|
|
84
|
+
size: memoized.entry.size
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const entry = !byDigest && index.find.sync(cache, key, opts)
|
|
88
|
+
if (!entry && !byDigest) {
|
|
89
|
+
throw new index.NotFoundError(cache, key)
|
|
90
|
+
}
|
|
91
|
+
const data = read.sync(
|
|
92
|
+
cache,
|
|
93
|
+
byDigest ? key : entry.integrity,
|
|
94
|
+
{
|
|
95
|
+
integrity: opts.integrity,
|
|
96
|
+
size: opts.size
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
const res = byDigest
|
|
100
|
+
? data
|
|
101
|
+
: {
|
|
102
|
+
metadata: entry.metadata,
|
|
103
|
+
data: data,
|
|
104
|
+
size: entry.size,
|
|
105
|
+
integrity: entry.integrity
|
|
106
|
+
}
|
|
107
|
+
if (opts.memoize && byDigest) {
|
|
108
|
+
memo.put.byDigest(cache, key, res, opts)
|
|
109
|
+
} else if (opts.memoize) {
|
|
110
|
+
memo.put(cache, entry, res.data, opts)
|
|
111
|
+
}
|
|
112
|
+
return res
|
|
113
|
+
}
|
|
114
|
+
|
|
66
115
|
module.exports.stream = getStream
|
|
67
116
|
function getStream (cache, key, opts) {
|
|
68
117
|
opts = GetOpts(opts)
|
|
@@ -113,7 +162,7 @@ function getStream (cache, key, opts) {
|
|
|
113
162
|
memoStream,
|
|
114
163
|
stream
|
|
115
164
|
)
|
|
116
|
-
}
|
|
165
|
+
}).catch(err => stream.emit('error', err))
|
|
117
166
|
return stream
|
|
118
167
|
}
|
|
119
168
|
|
package/lib/content/path.js
CHANGED
|
@@ -12,7 +12,7 @@ const ssri = require('ssri')
|
|
|
12
12
|
//
|
|
13
13
|
module.exports = contentPath
|
|
14
14
|
function contentPath (cache, integrity) {
|
|
15
|
-
const sri = ssri.parse(integrity, {single: true})
|
|
15
|
+
const sri = ssri.parse(integrity, { single: true })
|
|
16
16
|
// contentPath is the *strongest* algo given
|
|
17
17
|
return path.join.apply(path, [
|
|
18
18
|
contentDir(cache),
|
package/lib/content/read.js
CHANGED
|
@@ -54,8 +54,8 @@ function readStream (cache, integrity, opts) {
|
|
|
54
54
|
opts = ReadOpts(opts)
|
|
55
55
|
const stream = new PassThrough()
|
|
56
56
|
withContentSri(cache, integrity, (cpath, sri) => {
|
|
57
|
-
return lstatAsync(cpath).then(stat => ({cpath, sri, stat}))
|
|
58
|
-
}).then(({cpath, sri, stat}) => {
|
|
57
|
+
return lstatAsync(cpath).then(stat => ({ cpath, sri, stat }))
|
|
58
|
+
}).then(({ cpath, sri, stat }) => {
|
|
59
59
|
return pipe(
|
|
60
60
|
fs.createReadStream(cpath),
|
|
61
61
|
ssri.integrityStream({
|
|
@@ -95,7 +95,7 @@ module.exports.hasContent = hasContent
|
|
|
95
95
|
function hasContent (cache, integrity) {
|
|
96
96
|
if (!integrity) { return BB.resolve(false) }
|
|
97
97
|
return withContentSri(cache, integrity, (cpath, sri) => {
|
|
98
|
-
return lstatAsync(cpath).then(stat => ({size: stat.size, sri, stat}))
|
|
98
|
+
return lstatAsync(cpath).then(stat => ({ size: stat.size, sri, stat }))
|
|
99
99
|
}).catch(err => {
|
|
100
100
|
if (err.code === 'ENOENT') { return false }
|
|
101
101
|
if (err.code === 'EPERM') {
|
|
@@ -114,7 +114,7 @@ function hasContentSync (cache, integrity) {
|
|
|
114
114
|
return withContentSriSync(cache, integrity, (cpath, sri) => {
|
|
115
115
|
try {
|
|
116
116
|
const stat = fs.lstatSync(cpath)
|
|
117
|
-
return {size: stat.size, sri, stat}
|
|
117
|
+
return { size: stat.size, sri, stat }
|
|
118
118
|
} catch (err) {
|
|
119
119
|
if (err.code === 'ENOENT') { return false }
|
|
120
120
|
if (err.code === 'EPERM') {
|
|
@@ -141,12 +141,12 @@ function withContentSri (cache, integrity, fn) {
|
|
|
141
141
|
} else {
|
|
142
142
|
return BB.any(sri[sri.pickAlgorithm()].map(meta => {
|
|
143
143
|
return withContentSri(cache, meta, fn)
|
|
144
|
-
}, {concurrency: 1}))
|
|
144
|
+
}, { concurrency: 1 }))
|
|
145
145
|
.catch(err => {
|
|
146
146
|
if ([].some.call(err, e => e.code === 'ENOENT')) {
|
|
147
147
|
throw Object.assign(
|
|
148
148
|
new Error('No matching content found for ' + sri.toString()),
|
|
149
|
-
{code: 'ENOENT'}
|
|
149
|
+
{ code: 'ENOENT' }
|
|
150
150
|
)
|
|
151
151
|
} else {
|
|
152
152
|
throw err[0]
|
package/lib/content/write.js
CHANGED
|
@@ -36,11 +36,11 @@ function write (cache, data, opts) {
|
|
|
36
36
|
}
|
|
37
37
|
return BB.using(makeTmp(cache, opts), tmp => (
|
|
38
38
|
writeFileAsync(
|
|
39
|
-
tmp.target, data, {flag: 'wx'}
|
|
39
|
+
tmp.target, data, { flag: 'wx' }
|
|
40
40
|
).then(() => (
|
|
41
41
|
moveToDestination(tmp, cache, sri, opts)
|
|
42
42
|
))
|
|
43
|
-
)).then(() => ({integrity: sri, size: data.length}))
|
|
43
|
+
)).then(() => ({ integrity: sri, size: data.length }))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
module.exports.stream = writeStream
|
|
@@ -111,8 +111,8 @@ function pipeToTmp (inputStream, cache, tmpTarget, opts, errCheck) {
|
|
|
111
111
|
})
|
|
112
112
|
errCheck()
|
|
113
113
|
return pipe(inputStream, hashStream, outStream).then(() => {
|
|
114
|
-
return {integrity, size}
|
|
115
|
-
}
|
|
114
|
+
return { integrity, size }
|
|
115
|
+
}).catch(err => {
|
|
116
116
|
return rimraf(tmpTarget).then(() => { throw err })
|
|
117
117
|
})
|
|
118
118
|
})
|
package/lib/entry-index.js
CHANGED
|
@@ -64,7 +64,7 @@ function insert (cache, key, integrity, opts) {
|
|
|
64
64
|
)
|
|
65
65
|
}).then(
|
|
66
66
|
() => fixOwner.chownr(bucket, opts.uid, opts.gid)
|
|
67
|
-
).catch({code: 'ENOENT'}, () => {
|
|
67
|
+
).catch({ code: 'ENOENT' }, () => {
|
|
68
68
|
// There's a class of race conditions that happen when things get deleted
|
|
69
69
|
// during fixOwner, or between the two mkdirfix/chownr calls.
|
|
70
70
|
//
|
|
@@ -75,10 +75,36 @@ function insert (cache, key, integrity, opts) {
|
|
|
75
75
|
})
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
module.exports.insert.sync = insertSync
|
|
79
|
+
function insertSync (cache, key, integrity, opts) {
|
|
80
|
+
opts = IndexOpts(opts)
|
|
81
|
+
const bucket = bucketPath(cache, key)
|
|
82
|
+
const entry = {
|
|
83
|
+
key,
|
|
84
|
+
integrity: integrity && ssri.stringify(integrity),
|
|
85
|
+
time: Date.now(),
|
|
86
|
+
size: opts.size,
|
|
87
|
+
metadata: opts.metadata
|
|
88
|
+
}
|
|
89
|
+
fixOwner.mkdirfix.sync(path.dirname(bucket), opts.uid, opts.gid)
|
|
90
|
+
const stringified = JSON.stringify(entry)
|
|
91
|
+
fs.appendFileSync(
|
|
92
|
+
bucket, `\n${hashEntry(stringified)}\t${stringified}`
|
|
93
|
+
)
|
|
94
|
+
try {
|
|
95
|
+
fixOwner.chownr.sync(bucket, opts.uid, opts.gid)
|
|
96
|
+
} catch (err) {
|
|
97
|
+
if (err.code !== 'ENOENT') {
|
|
98
|
+
throw err
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return formatEntry(cache, entry)
|
|
102
|
+
}
|
|
103
|
+
|
|
78
104
|
module.exports.find = find
|
|
79
105
|
function find (cache, key) {
|
|
80
106
|
const bucket = bucketPath(cache, key)
|
|
81
|
-
return bucketEntries(
|
|
107
|
+
return bucketEntries(bucket).then(entries => {
|
|
82
108
|
return entries.reduce((latest, next) => {
|
|
83
109
|
if (next && next.key === key) {
|
|
84
110
|
return formatEntry(cache, next)
|
|
@@ -95,11 +121,36 @@ function find (cache, key) {
|
|
|
95
121
|
})
|
|
96
122
|
}
|
|
97
123
|
|
|
124
|
+
module.exports.find.sync = findSync
|
|
125
|
+
function findSync (cache, key) {
|
|
126
|
+
const bucket = bucketPath(cache, key)
|
|
127
|
+
try {
|
|
128
|
+
return bucketEntriesSync(bucket).reduce((latest, next) => {
|
|
129
|
+
if (next && next.key === key) {
|
|
130
|
+
return formatEntry(cache, next)
|
|
131
|
+
} else {
|
|
132
|
+
return latest
|
|
133
|
+
}
|
|
134
|
+
}, null)
|
|
135
|
+
} catch (err) {
|
|
136
|
+
if (err.code === 'ENOENT') {
|
|
137
|
+
return null
|
|
138
|
+
} else {
|
|
139
|
+
throw err
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
98
144
|
module.exports.delete = del
|
|
99
145
|
function del (cache, key, opts) {
|
|
100
146
|
return insert(cache, key, null, opts)
|
|
101
147
|
}
|
|
102
148
|
|
|
149
|
+
module.exports.delete.sync = delSync
|
|
150
|
+
function delSync (cache, key, opts) {
|
|
151
|
+
return insertSync(cache, key, null, opts)
|
|
152
|
+
}
|
|
153
|
+
|
|
103
154
|
module.exports.lsStream = lsStream
|
|
104
155
|
function lsStream (cache) {
|
|
105
156
|
const indexDir = bucketDir(cache)
|
|
@@ -116,7 +167,6 @@ function lsStream (cache) {
|
|
|
116
167
|
// "/cachename/<bucket 0xFF>/<bucket 0xFF>/*"
|
|
117
168
|
return readdirOrEmpty(subbucketPath).map(entry => {
|
|
118
169
|
const getKeyToEntry = bucketEntries(
|
|
119
|
-
cache,
|
|
120
170
|
path.join(subbucketPath, entry)
|
|
121
171
|
).reduce((acc, entry) => {
|
|
122
172
|
acc.set(entry.key, entry)
|
|
@@ -128,7 +178,7 @@ function lsStream (cache) {
|
|
|
128
178
|
const formatted = formatEntry(cache, entry)
|
|
129
179
|
formatted && stream.push(formatted)
|
|
130
180
|
}
|
|
131
|
-
}).catch({code: 'ENOENT'}, nop)
|
|
181
|
+
}).catch({ code: 'ENOENT' }, nop)
|
|
132
182
|
})
|
|
133
183
|
})
|
|
134
184
|
}).then(() => {
|
|
@@ -152,32 +202,39 @@ function ls (cache) {
|
|
|
152
202
|
})
|
|
153
203
|
}
|
|
154
204
|
|
|
155
|
-
function bucketEntries (
|
|
205
|
+
function bucketEntries (bucket, filter) {
|
|
156
206
|
return readFileAsync(
|
|
157
207
|
bucket, 'utf8'
|
|
158
|
-
).then(data =>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
208
|
+
).then(data => _bucketEntries(data, filter))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function bucketEntriesSync (bucket, filter) {
|
|
212
|
+
const data = fs.readFileSync(bucket, 'utf8')
|
|
213
|
+
return _bucketEntries(data, filter)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function _bucketEntries (data, filter) {
|
|
217
|
+
let entries = []
|
|
218
|
+
data.split('\n').forEach(entry => {
|
|
219
|
+
if (!entry) { return }
|
|
220
|
+
const pieces = entry.split('\t')
|
|
221
|
+
if (!pieces[1] || hashEntry(pieces[1]) !== pieces[0]) {
|
|
222
|
+
// Hash is no good! Corruption or malice? Doesn't matter!
|
|
223
|
+
// EJECT EJECT
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
let obj
|
|
227
|
+
try {
|
|
228
|
+
obj = JSON.parse(pieces[1])
|
|
229
|
+
} catch (e) {
|
|
230
|
+
// Entry is corrupted!
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
if (obj) {
|
|
234
|
+
entries.push(obj)
|
|
235
|
+
}
|
|
180
236
|
})
|
|
237
|
+
return entries
|
|
181
238
|
}
|
|
182
239
|
|
|
183
240
|
module.exports._bucketDir = bucketDir
|
|
@@ -225,8 +282,8 @@ function formatEntry (cache, entry) {
|
|
|
225
282
|
|
|
226
283
|
function readdirOrEmpty (dir) {
|
|
227
284
|
return readdirAsync(dir)
|
|
228
|
-
.catch({code: 'ENOENT'}, () => [])
|
|
229
|
-
.catch({code: 'ENOTDIR'}, () => [])
|
|
285
|
+
.catch({ code: 'ENOENT' }, () => [])
|
|
286
|
+
.catch({ code: 'ENOTDIR' }, () => [])
|
|
230
287
|
}
|
|
231
288
|
|
|
232
289
|
function nop () {
|
package/lib/util/fix-owner.js
CHANGED
|
@@ -27,18 +27,64 @@ function fixOwner (filepath, uid, gid) {
|
|
|
27
27
|
filepath,
|
|
28
28
|
typeof uid === 'number' ? uid : process.getuid(),
|
|
29
29
|
typeof gid === 'number' ? gid : process.getgid()
|
|
30
|
-
).catch({code: 'ENOENT'}, () => null)
|
|
30
|
+
).catch({ code: 'ENOENT' }, () => null)
|
|
31
31
|
)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
module.exports.chownr.sync = fixOwnerSync
|
|
35
|
+
function fixOwnerSync (filepath, uid, gid) {
|
|
36
|
+
if (!process.getuid) {
|
|
37
|
+
// This platform doesn't need ownership fixing
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (typeof uid !== 'number' && typeof gid !== 'number') {
|
|
41
|
+
// There's no permissions override. Nothing to do here.
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
if ((typeof uid === 'number' && process.getuid() === uid) &&
|
|
45
|
+
(typeof gid === 'number' && process.getgid() === gid)) {
|
|
46
|
+
// No need to override if it's already what we used.
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
chownr.sync(
|
|
51
|
+
filepath,
|
|
52
|
+
typeof uid === 'number' ? uid : process.getuid(),
|
|
53
|
+
typeof gid === 'number' ? gid : process.getgid()
|
|
54
|
+
)
|
|
55
|
+
} catch (err) {
|
|
56
|
+
if (err.code === 'ENOENT') {
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
34
62
|
module.exports.mkdirfix = mkdirfix
|
|
35
63
|
function mkdirfix (p, uid, gid, cb) {
|
|
36
64
|
return mkdirp(p).then(made => {
|
|
37
65
|
if (made) {
|
|
38
66
|
return fixOwner(made, uid, gid).then(() => made)
|
|
39
67
|
}
|
|
40
|
-
}).catch({code: 'EEXIST'}, () => {
|
|
68
|
+
}).catch({ code: 'EEXIST' }, () => {
|
|
41
69
|
// There's a race in mkdirp!
|
|
42
70
|
return fixOwner(p, uid, gid).then(() => null)
|
|
43
71
|
})
|
|
44
72
|
}
|
|
73
|
+
|
|
74
|
+
module.exports.mkdirfix.sync = mkdirfixSync
|
|
75
|
+
function mkdirfixSync (p, uid, gid) {
|
|
76
|
+
try {
|
|
77
|
+
const made = mkdirp.sync(p)
|
|
78
|
+
if (made) {
|
|
79
|
+
fixOwnerSync(made, uid, gid)
|
|
80
|
+
return made
|
|
81
|
+
}
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (err.code === 'EEXIST') {
|
|
84
|
+
fixOwnerSync(p, uid, gid)
|
|
85
|
+
return null
|
|
86
|
+
} else {
|
|
87
|
+
throw err
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
package/lib/verify.js
CHANGED
|
@@ -130,7 +130,7 @@ function garbageCollect (cache, opts) {
|
|
|
130
130
|
})
|
|
131
131
|
})
|
|
132
132
|
}
|
|
133
|
-
}, {concurrency: opts.concurrency}))
|
|
133
|
+
}, { concurrency: opts.concurrency }))
|
|
134
134
|
})
|
|
135
135
|
})
|
|
136
136
|
}
|
|
@@ -150,7 +150,7 @@ function verifyContent (filepath, sri) {
|
|
|
150
150
|
contentInfo.valid = false
|
|
151
151
|
})
|
|
152
152
|
}).then(() => contentInfo)
|
|
153
|
-
}).catch({code: 'ENOENT'}, () => ({size: 0, valid: false}))
|
|
153
|
+
}).catch({ code: 'ENOENT' }, () => ({ size: 0, valid: false }))
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
function rebuildIndex (cache, opts) {
|
|
@@ -183,7 +183,7 @@ function rebuildIndex (cache, opts) {
|
|
|
183
183
|
}
|
|
184
184
|
return BB.map(Object.keys(buckets), key => {
|
|
185
185
|
return rebuildBucket(cache, buckets[key], stats, opts)
|
|
186
|
-
}, {concurrency: opts.concurrency}).then(() => stats)
|
|
186
|
+
}, { concurrency: opts.concurrency }).then(() => stats)
|
|
187
187
|
})
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -200,7 +200,7 @@ function rebuildBucket (cache, bucket, stats, opts) {
|
|
|
200
200
|
metadata: entry.metadata,
|
|
201
201
|
size: entry.size
|
|
202
202
|
}).then(() => { stats.totalEntries++ })
|
|
203
|
-
}).catch({code: 'ENOENT'}, () => {
|
|
203
|
+
}).catch({ code: 'ENOENT' }, () => {
|
|
204
204
|
stats.rejectedEntries++
|
|
205
205
|
stats.missingContent++
|
|
206
206
|
})
|
package/locales/en.js
CHANGED
|
@@ -18,12 +18,15 @@ x.ls.stream = cache => ls.stream(cache)
|
|
|
18
18
|
|
|
19
19
|
x.get = (cache, key, opts) => get(cache, key, opts)
|
|
20
20
|
x.get.byDigest = (cache, hash, opts) => get.byDigest(cache, hash, opts)
|
|
21
|
+
x.get.sync = (cache, key, opts) => get.sync(cache, key, opts)
|
|
22
|
+
x.get.sync.byDigest = (cache, key, opts) => get.sync.byDigest(cache, key, opts)
|
|
21
23
|
x.get.stream = (cache, key, opts) => get.stream(cache, key, opts)
|
|
22
24
|
x.get.stream.byDigest = (cache, hash, opts) => get.stream.byDigest(cache, hash, opts)
|
|
23
25
|
x.get.copy = (cache, key, dest, opts) => get.copy(cache, key, dest, opts)
|
|
24
26
|
x.get.copy.byDigest = (cache, hash, dest, opts) => get.copy.byDigest(cache, hash, dest, opts)
|
|
25
27
|
x.get.info = (cache, key) => get.info(cache, key)
|
|
26
28
|
x.get.hasContent = (cache, hash) => get.hasContent(cache, hash)
|
|
29
|
+
x.get.hasContent.sync = (cache, hash) => get.hasContent.sync(cache, hash)
|
|
27
30
|
|
|
28
31
|
x.put = (cache, key, data, opts) => put(cache, key, data, opts)
|
|
29
32
|
x.put.stream = (cache, key, opts) => put.stream(cache, key, opts)
|
package/locales/en.json
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
"No cache entry for `%s` found in `%s`": "No cache entry for %s found in %s",
|
|
3
3
|
"Integrity verification failed for %s (%s)": "Integrity verification failed for %s (%s)",
|
|
4
4
|
"Bad data size: expected inserted data to be %s bytes, but got %s instead": "Bad data size: expected inserted data to be %s bytes, but got %s instead",
|
|
5
|
-
"Cache input stream was empty": "Cache input stream was empty"
|
|
6
|
-
|
|
5
|
+
"Cache input stream was empty": "Cache input stream was empty",
|
|
6
|
+
"Integrity check failed:\n Wanted: %s\n Found: %s": "Integrity check failed:\n Wanted: %s\n Found: %s"
|
|
7
|
+
}
|
package/locales/es.js
CHANGED
|
@@ -18,12 +18,15 @@ x.ls.flujo = cache => ls.stream(cache)
|
|
|
18
18
|
|
|
19
19
|
x.saca = (cache, clave, ops) => get(cache, clave, ops)
|
|
20
20
|
x.saca.porHacheo = (cache, hacheo, ops) => get.byDigest(cache, hacheo, ops)
|
|
21
|
+
x.saca.sinc = (cache, clave, ops) => get.sync(cache, clave, ops)
|
|
22
|
+
x.saca.sinc.porHacheo = (cache, hacheo, ops) => get.sync.byDigest(cache, hacheo, ops)
|
|
21
23
|
x.saca.flujo = (cache, clave, ops) => get.stream(cache, clave, ops)
|
|
22
24
|
x.saca.flujo.porHacheo = (cache, hacheo, ops) => get.stream.byDigest(cache, hacheo, ops)
|
|
23
25
|
x.sava.copia = (cache, clave, destino, opts) => get.copy(cache, clave, destino, opts)
|
|
24
26
|
x.sava.copia.porHacheo = (cache, hacheo, destino, opts) => get.copy.byDigest(cache, hacheo, destino, opts)
|
|
25
27
|
x.saca.info = (cache, clave) => get.info(cache, clave)
|
|
26
28
|
x.saca.tieneDatos = (cache, hacheo) => get.hasContent(cache, hacheo)
|
|
29
|
+
x.saca.tieneDatos.sinc = (cache, hacheo) => get.hasContent.sync(cache, hacheo)
|
|
27
30
|
|
|
28
31
|
x.mete = (cache, clave, datos, ops) => put(cache, clave, datos, ops)
|
|
29
32
|
x.mete.flujo = (cache, clave, ops) => put.stream(cache, clave, ops)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacache",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.3",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"content": "2",
|
|
6
6
|
"index": "5"
|
|
@@ -58,32 +58,32 @@
|
|
|
58
58
|
],
|
|
59
59
|
"license": "ISC",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"bluebird": "^3.5.
|
|
62
|
-
"chownr": "^1.
|
|
63
|
-
"figgy-pudding": "^3.1
|
|
64
|
-
"glob": "^7.1.
|
|
65
|
-
"graceful-fs": "^4.1.
|
|
66
|
-
"lru-cache": "^
|
|
61
|
+
"bluebird": "^3.5.5",
|
|
62
|
+
"chownr": "^1.1.1",
|
|
63
|
+
"figgy-pudding": "^3.5.1",
|
|
64
|
+
"glob": "^7.1.4",
|
|
65
|
+
"graceful-fs": "^4.1.15",
|
|
66
|
+
"lru-cache": "^5.1.1",
|
|
67
67
|
"mississippi": "^3.0.0",
|
|
68
68
|
"mkdirp": "^0.5.1",
|
|
69
69
|
"move-concurrently": "^1.0.1",
|
|
70
70
|
"promise-inflight": "^1.0.1",
|
|
71
|
-
"rimraf": "^2.6.
|
|
72
|
-
"ssri": "^6.0.
|
|
73
|
-
"unique-filename": "^1.1.
|
|
71
|
+
"rimraf": "^2.6.3",
|
|
72
|
+
"ssri": "^6.0.1",
|
|
73
|
+
"unique-filename": "^1.1.1",
|
|
74
74
|
"y18n": "^4.0.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"benchmark": "^2.1.4",
|
|
78
|
-
"chalk": "^2.
|
|
78
|
+
"chalk": "^2.4.2",
|
|
79
79
|
"cross-env": "^5.1.4",
|
|
80
|
-
"require-inject": "^1.4.
|
|
81
|
-
"standard": "^
|
|
82
|
-
"standard-version": "^
|
|
83
|
-
"tacks": "^1.
|
|
84
|
-
"tap": "^12.0
|
|
80
|
+
"require-inject": "^1.4.4",
|
|
81
|
+
"standard": "^12.0.1",
|
|
82
|
+
"standard-version": "^6.0.1",
|
|
83
|
+
"tacks": "^1.3.0",
|
|
84
|
+
"tap": "^12.7.0",
|
|
85
85
|
"weallbehave": "^1.2.0",
|
|
86
|
-
"weallcontribute": "^1.0.
|
|
86
|
+
"weallcontribute": "^1.0.9"
|
|
87
87
|
},
|
|
88
88
|
"config": {
|
|
89
89
|
"nyc": {
|
package/put.js
CHANGED
|
@@ -20,6 +20,7 @@ const PutOpts = figgyPudding({
|
|
|
20
20
|
gid: {},
|
|
21
21
|
single: {},
|
|
22
22
|
sep: {},
|
|
23
|
+
error: {},
|
|
23
24
|
strict: {}
|
|
24
25
|
})
|
|
25
26
|
|
|
@@ -28,7 +29,7 @@ function putData (cache, key, data, opts) {
|
|
|
28
29
|
opts = PutOpts(opts)
|
|
29
30
|
return write(cache, data, opts).then(res => {
|
|
30
31
|
return index.insert(
|
|
31
|
-
cache, key, res.integrity, opts.concat({size: res.size})
|
|
32
|
+
cache, key, res.integrity, opts.concat({ size: res.size })
|
|
32
33
|
).then(entry => {
|
|
33
34
|
if (opts.memoize) {
|
|
34
35
|
memo.put(cache, entry, data, opts)
|
|
@@ -63,7 +64,7 @@ function putStream (cache, key, opts) {
|
|
|
63
64
|
})
|
|
64
65
|
}, cb => {
|
|
65
66
|
contentStream.end(() => {
|
|
66
|
-
index.insert(cache, key, integrity, opts.concat({size})).then(entry => {
|
|
67
|
+
index.insert(cache, key, integrity, opts.concat({ size })).then(entry => {
|
|
67
68
|
if (opts.memoize) {
|
|
68
69
|
memo.put(cache, entry, Buffer.concat(memoData, memoTotal), opts)
|
|
69
70
|
}
|