[win] onlinstaller: support alternative update URL

This commit is contained in:
SimplestStudio
2025-04-30 14:22:11 +03:00
parent 88f0a8f2b3
commit ec7bac3b75
3 changed files with 17 additions and 0 deletions

View File

@ -197,6 +197,17 @@ CDownloader::~CDownloader()
delete pimpl, pimpl = nullptr;
}
bool CDownloader::isUrlAccessible(const wstring &url)
{
if (url.empty())
return false;
DWORD dwFileSize = 0;
Connection conn;
int hr = initConnection(url, dwFileSize, conn);
return hr == ERROR_SUCCESS;
}
void CDownloader::queryContentLenght(const wstring &url)
{
if (url.empty() || pimpl->m_lock)

View File

@ -52,6 +52,7 @@ public:
CDownloader();
~CDownloader();
bool isUrlAccessible(const wstring &url);
void queryContentLenght(const wstring &url);
void downloadFile(const wstring &url, const wstring &filePath);
void start();

View File

@ -842,6 +842,11 @@ CDownloader* MainWindow::startDownload(const std::wstring &install_type, const s
#endif
JsonObject package_type = win.value(install_type).toObject();
tstring url = package_type.value(_T("url")).toTString();
tstring url2 = package_type.value(_T("url2")).toTString();
NS_Logger::WriteLog(_T("Primary package URL: ") + url + _T("\nSecondary package URL: ") + url2);
if ((url.empty() || !dnl->isUrlAccessible(url)) && !url2.empty())
url = url2;
// tstring hash = package_type.value(_T("md5")).toTString();
// std::transform(hash.begin(), hash.end(), hash.begin(), ::tolower);
NS_File::removeFile(tmp_path);