[RAPPS] Use the provided SizeBytes for the progress,

when the host does not give a file size
This commit is contained in:
Mark Jansen 2020-03-17 20:54:45 +01:00
parent bcd301d136
commit 4439b53800
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
3 changed files with 20 additions and 7 deletions

View file

@ -73,13 +73,17 @@ struct DownloadInfo
{
DownloadInfo() {}
DownloadInfo(const CAvailableApplicationInfo& AppInfo)
:szUrl(AppInfo.m_szUrlDownload), szName(AppInfo.m_szName), szSHA1(AppInfo.m_szSHA1)
: szUrl(AppInfo.m_szUrlDownload)
, szName(AppInfo.m_szName)
, szSHA1(AppInfo.m_szSHA1)
, SizeInBytes(AppInfo.m_SizeBytes)
{
}
ATL::CStringW szUrl;
ATL::CStringW szName;
ATL::CStringW szSHA1;
ULONG SizeInBytes;
};
struct DownloadParam
@ -669,8 +673,7 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
// query content length
HttpQueryInfoW(hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &dwContentLen, &dwStatusLen, NULL);
}
if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
{
// force passive mode on FTP
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
@ -687,8 +690,16 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
if (!dwContentLen)
{
// content-length is not known, enable marquee mode
ProgressBar.SetMarquee(TRUE);
// Someone was nice enough to add this, let's use it
if (InfoArray[iAppId].SizeInBytes)
{
dwContentLen = InfoArray[iAppId].SizeInBytes;
}
else
{
// content-length is not known, enable marquee mode
ProgressBar.SetMarquee(TRUE);
}
}
free(urlComponents.lpszScheme);