msi: Fix download of installer packages. Return errors from msi_download_file and copy_package_to_temp.
This commit is contained in:
parent
4e7389e44b
commit
ff2aa7e3a6
|
@ -757,7 +757,7 @@ extern MSICONDITION MSI_EvaluateConditionW( MSIPACKAGE *, LPCWSTR );
|
|||
extern UINT MSI_GetComponentStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
|
||||
extern UINT MSI_GetFeatureStateW( MSIPACKAGE *, LPCWSTR, INSTALLSTATE *, INSTALLSTATE * );
|
||||
extern UINT WINAPI MSI_SetFeatureStateW(MSIPACKAGE*, LPCWSTR, INSTALLSTATE );
|
||||
extern LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename );
|
||||
extern UINT msi_download_file( LPCWSTR szUrl, LPWSTR filename );
|
||||
extern UINT msi_package_add_info(MSIPACKAGE *, DWORD, DWORD, LPCWSTR, LPWSTR);
|
||||
extern UINT msi_package_add_media_disk(MSIPACKAGE *, DWORD, DWORD, DWORD, LPWSTR, LPWSTR);
|
||||
extern UINT msi_clone_properties(MSIPACKAGE *);
|
||||
|
|
|
@ -833,7 +833,7 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
|
|||
* we should read all the tables to memory, then open the
|
||||
* database to read binary streams on demand.
|
||||
*/
|
||||
static LPCWSTR copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
|
||||
static UINT copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
|
||||
{
|
||||
WCHAR path[MAX_PATH];
|
||||
|
||||
|
@ -842,16 +842,16 @@ static LPCWSTR copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
|
|||
|
||||
if( !CopyFileW( szPackage, filename, FALSE ) )
|
||||
{
|
||||
UINT error = GetLastError();
|
||||
ERR("failed to copy package %s to %s (%u)\n", debugstr_w(szPackage), debugstr_w(filename), error);
|
||||
DeleteFileW( filename );
|
||||
ERR("failed to copy package %s\n", debugstr_w(szPackage) );
|
||||
return szPackage;
|
||||
return error;
|
||||
}
|
||||
|
||||
TRACE("Opening relocated package %s\n", debugstr_w( filename ));
|
||||
return filename;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename )
|
||||
UINT msi_download_file( LPCWSTR szUrl, LPWSTR filename )
|
||||
{
|
||||
LPINTERNET_CACHE_ENTRY_INFOW cache_entry;
|
||||
DWORD size = 0;
|
||||
|
@ -867,20 +867,24 @@ LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename )
|
|||
cache_entry = HeapAlloc( GetProcessHeap(), 0, size );
|
||||
if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) )
|
||||
{
|
||||
UINT error = GetLastError();
|
||||
HeapFree( GetProcessHeap(), 0, cache_entry );
|
||||
return szUrl;
|
||||
return error;
|
||||
}
|
||||
|
||||
lstrcpyW( filename, cache_entry->lpszLocalFileName );
|
||||
HeapFree( GetProcessHeap(), 0, cache_entry );
|
||||
return filename;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL );
|
||||
if ( FAILED(hr) )
|
||||
return szUrl;
|
||||
{
|
||||
WARN("failed to download %s to cache file\n", debugstr_w(szUrl));
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
}
|
||||
|
||||
return filename;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static UINT msi_get_local_package_name( LPWSTR path )
|
||||
|
@ -925,7 +929,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
|||
MSIHANDLE handle;
|
||||
LPWSTR ptr, base_url = NULL;
|
||||
UINT r;
|
||||
WCHAR temppath[MAX_PATH], localfile[MAX_PATH];
|
||||
WCHAR temppath[MAX_PATH], localfile[MAX_PATH], cachefile[MAX_PATH];
|
||||
LPCWSTR file = szPackage;
|
||||
|
||||
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
|
||||
|
@ -952,9 +956,15 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
|||
{
|
||||
if ( UrlIsW( szPackage, URLIS_URL ) )
|
||||
{
|
||||
file = msi_download_file( szPackage, temppath );
|
||||
if ( file != szPackage )
|
||||
file = copy_package_to_temp( file, temppath );
|
||||
r = msi_download_file( szPackage, cachefile );
|
||||
if ( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
|
||||
r = copy_package_to_temp( cachefile, temppath );
|
||||
if ( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
|
||||
file = temppath;
|
||||
|
||||
base_url = strdupW( szPackage );
|
||||
if ( !base_url )
|
||||
|
@ -964,7 +974,13 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
|||
if (ptr) *(ptr + 1) = '\0';
|
||||
}
|
||||
else
|
||||
file = copy_package_to_temp( szPackage, temppath );
|
||||
{
|
||||
r = copy_package_to_temp( szPackage, temppath );
|
||||
if ( r != ERROR_SUCCESS )
|
||||
return r;
|
||||
|
||||
file = temppath;
|
||||
}
|
||||
|
||||
r = msi_get_local_package_name( localfile );
|
||||
if (r != ERROR_SUCCESS)
|
||||
|
@ -979,6 +995,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
|||
return GetLastError();
|
||||
}
|
||||
|
||||
TRACE("Opening relocated package %s\n", debugstr_w( file ));
|
||||
|
||||
/* transforms that add binary streams require that we open the database
|
||||
* read/write, which is safe because we always create a copy that is thrown
|
||||
* away when we're done.
|
||||
|
|
Loading…
Reference in New Issue