[2232] Fix Missing Preferences

Fixes an issue that could present on clean installs where the EDSM keys weren't generated properly.

When the heck did this bug get introduced???
This commit is contained in:
David Sangrey committed 2024-05-12 23:16:45 -04:00
1 parent 456db7b132
commit ad16f0666d
1 file changed
+14
+14
View File
@@ -491,6 +491,20 @@ def credentials(cmdr: str) -> tuple[str, str] | None:
edsm_usernames = config.get_list('edsm_usernames')
edsm_apikeys = config.get_list('edsm_apikeys')
if not edsm_usernames: # https://github.com/EDCD/EDMarketConnector/issues/2232
edsm_usernames = ["" for _ in range(len(cmdrs))]
config.set('edsm_usernames', edsm_usernames)
else: # Check for Mismatched Length - fill with null values.
if len(edsm_usernames) < len(cmdrs):
edsm_usernames.extend(["" for _ in range(len(cmdrs) - len(edsm_usernames))])
if not edsm_apikeys:
edsm_apikeys = ["" for _ in range(len(cmdrs))]
config.set('edsm_apikeys', edsm_apikeys)
else: # Check for Mismatched Length - fill with null values.
if len(edsm_apikeys) < len(cmdrs):
edsm_apikeys.extend(["" for _ in range(len(cmdrs) - len(edsm_apikeys))])
if cmdr in cmdrs and len(cmdrs) == len(edsm_usernames) == len(edsm_apikeys):
idx = cmdrs.index(cmdr)
if idx < len(edsm_usernames) and idx < len(edsm_apikeys):