Add try/except around download

This commit is contained in:
amcmanu3 2022-08-31 19:59:46 -04:00
parent b274f0d3b0
commit bd38fcd6e4

View File

@ -1115,6 +1115,7 @@ class ServerInstance:
) )
else: else:
# downloads zip from remote url # downloads zip from remote url
try:
bedrock_url = Helpers.get_latest_bedrock_url() bedrock_url = Helpers.get_latest_bedrock_url()
if bedrock_url.lower().startswith("https"): if bedrock_url.lower().startswith("https"):
urllib.request.urlretrieve( urllib.request.urlretrieve(
@ -1128,11 +1129,19 @@ class ServerInstance:
FileHelpers.unzip_file(unzip_path) FileHelpers.unzip_file(unzip_path)
# adjusts permissions for execution if os is not windows # adjusts permissions for execution if os is not windows
if not self.helper.is_os_windows(): if not self.helper.is_os_windows():
os.chmod(os.path.join(self.settings["path"], "bedrock_server"), 0o0744) os.chmod(
os.path.join(self.settings["path"], "bedrock_server"), 0o0744
)
# we'll delete the zip we downloaded now # we'll delete the zip we downloaded now
os.remove(os.path.join(self.settings["path"], "bedrock_server.zip")) os.remove(os.path.join(self.settings["path"], "bedrock_server.zip"))
downloaded = True downloaded = True
except Exception as e:
logger.critical(
f"Failed to download bedrock executable for update \n{e}"
)
downloaded = True
return
while self.stats_helper.get_server_stats()["updating"]: while self.stats_helper.get_server_stats()["updating"]:
if downloaded and not self.is_backingup: if downloaded and not self.is_backingup: