From 0ad0160b7ce8e17053c6c255cd34ccd845d291fc Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 29 Jan 2021 17:23:11 -0500 Subject: [PATCH] bin/rebuildPad.js: Fix check for existing rev --- bin/rebuildPad.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/rebuildPad.js b/bin/rebuildPad.js index 870bbcc4a..1bc942fe2 100644 --- a/bin/rebuildPad.js +++ b/bin/rebuildPad.js @@ -56,9 +56,7 @@ const newPadId = process.argv[4] || `${padId}-rebuilt`; newPad.pool.numToAttrib = oldPad.pool.numToAttrib; for (let curRevNum = 0; curRevNum <= newRevHead; curRevNum++) { const rev = await db.get(`pad:${padId}:revs:${curRevNum}`); - if (rev.meta) { - throw new Error('The specified revision number could not be found.'); - } + if (!rev || !rev.meta) throw new Error('The specified revision number could not be found.'); const newRevNum = ++newPad.head; const newRevId = `pad:${newPad.id}:revs:${newRevNum}`; await Promise.all([