Flush pending puths regardless of auth

This commit is contained in:
Daniel Lugo 2021-09-16 13:58:14 -04:00
parent 6d898baa2a
commit b829f0dc98

View file

@ -174,10 +174,7 @@ const auth = (alias, pass) => {
lastAlias = alias lastAlias = alias
lastPass = pass lastPass = pass
lastPair = ack.sea lastPair = ack.sea
logger.info( logger.info('Auth successful, credentials cached.')
'Auth successful, credentials cached, will now flush pending puts.'
)
flushPendingPuts()
res(ack.sea) res(ack.sea)
} else { } else {
rej(new Error('Auth: ack.sea undefined')) rej(new Error('Auth: ack.sea undefined'))
@ -200,6 +197,9 @@ const autoAuth = async () => {
} }
const flushPendingPuts = () => { const flushPendingPuts = () => {
if (isAuthing || isForging) {
throw new Error('Tried to flush pending puts while authing or forging.')
}
const ids = mapValues(pendingPuts, pendingPutsForPath => const ids = mapValues(pendingPuts, pendingPutsForPath =>
pendingPutsForPath.map(pp => pp.id) pendingPutsForPath.map(pp => pp.id)
) )
@ -313,10 +313,12 @@ const forge = () => {
logger.info('Finished reforging, will now auto-auth') logger.info('Finished reforging, will now auto-auth')
autoAuth().then(() => { autoAuth().then(() => {
isForging = false isForging = false
flushPendingPuts()
}) })
} else { } else {
logger.info('Finished forging, will now auto-auth') logger.info('Finished forging, will now auto-auth')
isForging = false isForging = false
flushPendingPuts()
} }
} }