Skip to content

Commit 7436d29

Browse files
sanchaezJoachimHenze
authored andcommitted
[0.4.8] cherry-pick [RAPPS] Use FTP in passive mode
This should finally fix FTP downloads in RAPPS. (cherry picked from commit a6d2172) cherry-picked by Joachim Henze
1 parent 89506d7 commit 7436d29

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

base/applications/rapps/loaddlg.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
603603
LPCWSTR szCaption = static_cast<DownloadParam*>(param)->szCaption;
604604
ATL::CStringW szNewCaption;
605605

606+
const DWORD dwUrlConnectFlags = INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION;
607+
606608
if (InfoArray.GetSize() <= 0)
607609
{
608610
MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD);
@@ -709,16 +711,6 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
709711
if (!hOpen)
710712
goto end;
711713

712-
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
713-
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION,
714-
0);
715-
716-
if (!hFile)
717-
{
718-
MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2);
719-
goto end;
720-
}
721-
722714
dwStatusLen = sizeof(dwStatus);
723715

724716
memset(&urlComponents, 0, sizeof(urlComponents));
@@ -737,6 +729,15 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
737729

738730
if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
739731
{
732+
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
733+
dwUrlConnectFlags,
734+
0);
735+
if (!hFile)
736+
{
737+
MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2);
738+
goto end;
739+
}
740+
740741
// query connection
741742
if (!HttpQueryInfoW(hFile, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwStatus, &dwStatusLen, NULL))
742743
goto end;
@@ -753,6 +754,16 @@ DWORD WINAPI CDownloadManager::ThreadFunc(LPVOID param)
753754

754755
if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
755756
{
757+
// force passive mode on FTP
758+
hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
759+
dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
760+
0);
761+
if (!hFile)
762+
{
763+
MessageBox_LoadString(hMainWnd, IDS_UNABLE_TO_DOWNLOAD2);
764+
goto end;
765+
}
766+
756767
dwContentLen = FtpGetFileSize(hFile, &dwStatus);
757768
}
758769

0 commit comments

Comments
 (0)