diff --git a/lib/verify.js b/lib/verify.js index 80d59bd..3468bc6 100644 --- a/lib/verify.js +++ b/lib/verify.js @@ -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++ diff --git a/test/verify.js b/test/verify.js index 5ce91d0..5bd0712 100644 --- a/test/verify.js +++ b/test/verify.js @@ -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') + }) + }) + }) +})