mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
[win] onlinstaller: support alternative update URL
This commit is contained in:
@ -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)
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user