Skip to content
This repository was archived by the owner on Jul 3, 2019. It is now read-only.

Commit c614a19

Browse files
jfmartinezzkat
authored andcommitted
fix(verify): size param no longer lost in a verify (#131)
Fixes a bug were after the cache was verified the 'size' parameter was lost from the index of the entry. Fixes: #130
1 parent 41e12c1 commit c614a19

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

lib/verify.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ function rebuildBucket (cache, bucket, stats, opts) {
197197
return index.insert(cache, entry.key, entry.integrity, {
198198
uid: opts.uid,
199199
gid: opts.gid,
200-
metadata: entry.metadata
200+
metadata: entry.metadata,
201+
size: entry.size
201202
}).then(() => { stats.totalEntries++ })
202203
}).catch({code: 'ENOENT'}, () => {
203204
stats.rejectedEntries++

test/verify.js

+37
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,40 @@ test('writes a file with last verification time', t => {
210210
})
211211

212212
test('fixes permissions and users on cache contents')
213+
214+
test('re-builds the index with the size parameter', t => {
215+
const KEY2 = KEY + 'aaa'
216+
const KEY3 = KEY + 'bbb'
217+
return mockCache().then(() => {
218+
return BB.join(
219+
index.insert(CACHE, KEY2, INTEGRITY, {
220+
metadata: 'haayyyy',
221+
size: 20
222+
}),
223+
index.insert(CACHE, KEY3, INTEGRITY, {
224+
metadata: 'haayyyy again',
225+
size: 30
226+
}))
227+
}).then(() => {
228+
return index.ls(CACHE).then((newEntries) => {
229+
return verify(CACHE)
230+
.then(stats => {
231+
t.deepEqual({
232+
verifiedContent: stats.verifiedContent,
233+
rejectedEntries: stats.rejectedEntries,
234+
totalEntries: stats.totalEntries
235+
}, {
236+
verifiedContent: 1,
237+
rejectedEntries: 0,
238+
totalEntries: 3
239+
}, 'reported relevant changes')
240+
return index.ls(CACHE)
241+
}).then(entries => {
242+
entries[KEY].time = newEntries[KEY].time
243+
entries[KEY2].time = newEntries[KEY2].time
244+
entries[KEY3].time = newEntries[KEY3].time
245+
t.deepEqual(entries, newEntries, 'original index entries not preserved')
246+
})
247+
})
248+
})
249+
})

0 commit comments

Comments
 (0)