mirror of
https://github.com/unraid/api.git
synced 2026-01-09 18:20:12 -06:00
fix: make sure lastKnownKey is updated correctly
This commit is contained in:
13
app/index.ts
13
app/index.ts
@@ -120,9 +120,6 @@ am(async () => {
|
||||
mothership.close();
|
||||
coreLogger.debug('Disconnected from mothership\'s subscription endpoint.');
|
||||
|
||||
// Record last known key
|
||||
lastKnownApiKey = newApiKey;
|
||||
|
||||
// Since we no longer have a key and
|
||||
// everything is disconnected we can bail
|
||||
if (newApiKey === undefined) {
|
||||
@@ -130,8 +127,6 @@ am(async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
apiManagerLogger.debug('Replacing my_servers key. Last known key was %s. New key is %s', lastKnownApiKey, newApiKey);
|
||||
|
||||
// We've never had a key before so let's start the internal API connection
|
||||
// That'll then start the relay connection to mothership
|
||||
if (!hasFirstKey && lastKnownApiKey === undefined) {
|
||||
@@ -146,9 +141,17 @@ am(async () => {
|
||||
|
||||
// Mark this as being done
|
||||
hasFirstKey = true;
|
||||
|
||||
// Record new key
|
||||
apiManagerLogger.debug('Setting my_servers key. Key is "%s".', newApiKey);
|
||||
lastKnownApiKey = newApiKey;
|
||||
return;
|
||||
}
|
||||
|
||||
// Record last known key
|
||||
apiManagerLogger.debug('Replacing my_servers key. Last known key was "%s". New key is "%s".', lastKnownApiKey, newApiKey);
|
||||
lastKnownApiKey = newApiKey;
|
||||
|
||||
// Stop internal connection
|
||||
sockets.internal?.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user