Skip to content

Commit

Permalink
fix(verify): size param no longer lost in a verify
Browse files Browse the repository at this point in the history
Fixes a bug were after the cache was verified the 'size' parameter was
lost from the index of the entry.

Fixes: zkat#130
  • Loading branch information
jfmartinez committed May 7, 2018
1 parent 41e12c1 commit 0d0a98e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ function rebuildBucket (cache, bucket, stats, opts) {
return index.insert(cache, entry.key, entry.integrity, {
uid: opts.uid,
gid: opts.gid,
metadata: entry.metadata
metadata: entry.metadata,
size: entry.size
}).then(() => { stats.totalEntries++ })
}).catch({code: 'ENOENT'}, () => {
stats.rejectedEntries++
Expand Down
37 changes: 37 additions & 0 deletions test/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,40 @@ test('writes a file with last verification time', t => {
})

test('fixes permissions and users on cache contents')

test('re-builds the index with the size parameter', t => {
const KEY2 = KEY + 'aaa'
const KEY3 = KEY + 'bbb'
return mockCache().then(() => {
return BB.join(
index.insert(CACHE, KEY2, INTEGRITY, {
metadata: 'haayyyy',
size: 20
}),
index.insert(CACHE, KEY3, INTEGRITY, {
metadata: 'haayyyy again',
size: 30
}))
}).then(() => {
return index.ls(CACHE).then((newEntries) => {
return verify(CACHE)
.then(stats => {
t.deepEqual({
verifiedContent: stats.verifiedContent,
rejectedEntries: stats.rejectedEntries,
totalEntries: stats.totalEntries
}, {
verifiedContent: 1,
rejectedEntries: 0,
totalEntries: 3
}, 'reported relevant changes')
return index.ls(CACHE)
}).then(entries => {
entries[KEY].time = newEntries[KEY].time
entries[KEY2].time = newEntries[KEY2].time
entries[KEY3].time = newEntries[KEY3].time
t.deepEqual(entries, newEntries, 'original index entries not preserved')
})
})
})
})

0 comments on commit 0d0a98e

Please sign in to comment.