Fix download verification logic for custom OLS binaries

Change download verification to check file existence and size instead of
relying on return code. The wget command succeeds but install_utils.call()
may not return 0. Now verifies downloaded file exists and is at least 1MB.
This commit is contained in:
usmannasir
2025-11-05 06:08:48 +05:00
parent 73ec9950ec
commit 32a7442dba

View File

@@ -231,14 +231,20 @@ class InstallCyberPanel:
# Use wget for better progress display # Use wget for better progress display
command = f'wget -q --show-progress {url} -O {destination}' command = f'wget -q --show-progress {url} -O {destination}'
result = install_utils.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) install_utils.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
if result == 0 and os.path.exists(destination): # Check if file was downloaded successfully by verifying it exists and has reasonable size
if os.path.exists(destination):
file_size = os.path.getsize(destination) file_size = os.path.getsize(destination)
InstallCyberPanel.stdOut(f"Downloaded successfully ({file_size / (1024*1024):.2f} MB)", 1) # Verify file size is reasonable (at least 1MB for a real binary)
return True if file_size > 1048576: # 1MB
InstallCyberPanel.stdOut(f"Downloaded successfully ({file_size / (1024*1024):.2f} MB)", 1)
return True
else:
InstallCyberPanel.stdOut(f"ERROR: Downloaded file too small ({file_size} bytes)", 1)
return False
else: else:
InstallCyberPanel.stdOut("ERROR: Download failed", 1) InstallCyberPanel.stdOut("ERROR: Download failed - file not found", 1)
return False return False
except Exception as msg: except Exception as msg: