prevent using empty cached version

This commit is contained in:
Alan Hamlett 2022-01-05 04:15:10 -08:00
parent c09767b58d
commit 033c07f070

View File

@ -725,10 +725,7 @@ def getLatestCliVersion():
try:
configs = parseConfigFile(INTERNAL_CONFIG_FILE)
if configs:
if configs.has_option('internal', 'cli_version'):
last_version = configs.get('internal', 'cli_version')
if last_version and configs.has_option('internal', 'cli_version_last_modified'):
last_modified = configs.get('internal', 'cli_version_last_modified')
last_modified, last_version = lastModifiedAndVersion(configs)
except:
log(DEBUG, traceback.format_exc())
@ -762,6 +759,17 @@ def getLatestCliVersion():
return None
def lastModifiedAndVersion(configs):
last_modified, last_version = None, None
if configs.has_option('internal', 'cli_version'):
last_version = configs.get('internal', 'cli_version')
if last_version and configs.has_option('internal', 'cli_version_last_modified'):
last_modified = configs.get('internal', 'cli_version_last_modified')
if last_modified and last_version and extractVersion(last_version):
return last_modified, last_version
return None, None
def extractVersion(text):
pattern = re.compile(r"([0-9]+\.[0-9]+\.[0-9]+)")
match = pattern.search(text)