mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 20:34:59 +00:00
[RAPPS] Allow database to override download filename (#7668)
http://example.com/setup.exe?foo=bar needs to use be able to use setup.exe as the filename.
This commit is contained in:
parent
7e52f64044
commit
a23db39c8a
2 changed files with 13 additions and 14 deletions
|
@ -82,6 +82,7 @@ enum InstallerType
|
||||||
#define DB_REGNAME L"RegName"
|
#define DB_REGNAME L"RegName"
|
||||||
#define DB_INSTALLER L"Installer"
|
#define DB_INSTALLER L"Installer"
|
||||||
#define DB_SCOPE L"Scope" // User or Machine
|
#define DB_SCOPE L"Scope" // User or Machine
|
||||||
|
#define DB_SAVEAS L"SaveAs"
|
||||||
|
|
||||||
#define DB_GENINSTSECTION L"Generate"
|
#define DB_GENINSTSECTION L"Generate"
|
||||||
#define GENERATE_ARPSUBKEY L"RApps" // Our uninstall data is stored here
|
#define GENERATE_ARPSUBKEY L"RApps" // Our uninstall data is stored here
|
||||||
|
|
|
@ -144,6 +144,10 @@ struct DownloadInfo
|
||||||
IType = AppInfo.GetInstallerType();
|
IType = AppInfo.GetInstallerType();
|
||||||
if (IType == INSTALLER_GENERATE)
|
if (IType == INSTALLER_GENERATE)
|
||||||
szPackageName = AppInfo.szIdentifier;
|
szPackageName = AppInfo.szIdentifier;
|
||||||
|
|
||||||
|
CConfigParser *cfg = static_cast<const CAvailableApplicationInfo&>(AppInfo).GetConfigParser();
|
||||||
|
if (cfg)
|
||||||
|
cfg->GetString(DB_SAVEAS, szFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Equal(const DownloadInfo &other) const
|
bool Equal(const DownloadInfo &other) const
|
||||||
|
@ -157,6 +161,7 @@ struct DownloadInfo
|
||||||
CStringW szName;
|
CStringW szName;
|
||||||
CStringW szSHA1;
|
CStringW szSHA1;
|
||||||
CStringW szPackageName;
|
CStringW szPackageName;
|
||||||
|
CStringW szFileName;
|
||||||
ULONG SizeInBytes;
|
ULONG SizeInBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -719,7 +724,7 @@ CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info)
|
||||||
|
|
||||||
CStringW str;
|
CStringW str;
|
||||||
CPathW Path;
|
CPathW Path;
|
||||||
PCWSTR p, q;
|
PCWSTR p;
|
||||||
|
|
||||||
ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus, dwStatusLen;
|
ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus, dwStatusLen;
|
||||||
ULONG dwCurrentBytesRead = 0;
|
ULONG dwCurrentBytesRead = 0;
|
||||||
|
@ -734,7 +739,7 @@ CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info)
|
||||||
const DWORD dwUrlConnectFlags =
|
const DWORD dwUrlConnectFlags =
|
||||||
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION;
|
INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_KEEP_CONNECTION;
|
||||||
URL_COMPONENTSW urlComponents;
|
URL_COMPONENTSW urlComponents;
|
||||||
size_t urlLength, filenameLength;
|
size_t urlLength;
|
||||||
unsigned char lpBuffer[4096];
|
unsigned char lpBuffer[4096];
|
||||||
|
|
||||||
// Change caption to show the currently downloaded app
|
// Change caption to show the currently downloaded app
|
||||||
|
@ -768,7 +773,6 @@ CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info)
|
||||||
|
|
||||||
// build the path for the download
|
// build the path for the download
|
||||||
p = wcsrchr(Info.szUrl.GetString(), L'/');
|
p = wcsrchr(Info.szUrl.GetString(), L'/');
|
||||||
q = wcsrchr(Info.szUrl.GetString(), L'?');
|
|
||||||
|
|
||||||
// do we have a final slash separator?
|
// do we have a final slash separator?
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -777,14 +781,6 @@ CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare the tentative length of the filename, maybe we've to remove part of it later on
|
|
||||||
filenameLength = wcslen(p) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
/* do we have query arguments in the target URL after the filename? account for them
|
|
||||||
(e.g. https://example.org/myfile.exe?no_adware_plz) */
|
|
||||||
if (q && q > p && (q - p) > 0)
|
|
||||||
filenameLength -= wcslen(q - 1) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
// is the path valid? can we access it?
|
// is the path valid? can we access it?
|
||||||
if (GetFileAttributesW(Path) == INVALID_FILE_ATTRIBUTES)
|
if (GetFileAttributesW(Path) == INVALID_FILE_ATTRIBUTES)
|
||||||
{
|
{
|
||||||
|
@ -803,9 +799,11 @@ CDownloadManager::PerformDownloadAndInstall(const DownloadInfo &Info)
|
||||||
break;
|
break;
|
||||||
case DLTYPE_APPLICATION:
|
case DLTYPE_APPLICATION:
|
||||||
{
|
{
|
||||||
CStringW str = p + 1; // use the filename retrieved from URL
|
CStringW name = Info.szFileName;
|
||||||
UrlUnescapeAndMakeFileNameValid(str);
|
if (name.IsEmpty())
|
||||||
Path += str;
|
name = p + 1; // use the filename retrieved from URL
|
||||||
|
UrlUnescapeAndMakeFileNameValid(name);
|
||||||
|
Path += name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue