From b829f0dc98cefa044c00ed33857502f9a637ebf5 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 16 Sep 2021 13:58:14 -0400 Subject: [PATCH] Flush pending puths regardless of auth --- utils/GunSmith/GunSmith.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/GunSmith/GunSmith.js b/utils/GunSmith/GunSmith.js index 57563137..81570ec4 100644 --- a/utils/GunSmith/GunSmith.js +++ b/utils/GunSmith/GunSmith.js @@ -174,10 +174,7 @@ const auth = (alias, pass) => { lastAlias = alias lastPass = pass lastPair = ack.sea - logger.info( - 'Auth successful, credentials cached, will now flush pending puts.' - ) - flushPendingPuts() + logger.info('Auth successful, credentials cached.') res(ack.sea) } else { rej(new Error('Auth: ack.sea undefined')) @@ -200,6 +197,9 @@ const autoAuth = async () => { } const flushPendingPuts = () => { + if (isAuthing || isForging) { + throw new Error('Tried to flush pending puts while authing or forging.') + } const ids = mapValues(pendingPuts, pendingPutsForPath => pendingPutsForPath.map(pp => pp.id) ) @@ -313,10 +313,12 @@ const forge = () => { logger.info('Finished reforging, will now auto-auth') autoAuth().then(() => { isForging = false + flushPendingPuts() }) } else { logger.info('Finished forging, will now auto-auth') isForging = false + flushPendingPuts() } }