Handle copying of the install package to a temporary file in one place
only.
This commit is contained in:
parent
0c9468d66b
commit
786920b7b6
|
@ -199,41 +199,21 @@ UINT WINAPI MsiInstallProductW(LPCWSTR szPackagePath, LPCWSTR szCommandLine)
|
||||||
MSIPACKAGE *package = NULL;
|
MSIPACKAGE *package = NULL;
|
||||||
UINT r;
|
UINT r;
|
||||||
MSIHANDLE handle;
|
MSIHANDLE handle;
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
WCHAR filename[MAX_PATH];
|
|
||||||
static const WCHAR szMSI[] = {'M','S','I',0};
|
|
||||||
|
|
||||||
FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
|
FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
|
||||||
|
|
||||||
r = MsiVerifyPackageW(szPackagePath);
|
r = MSI_OpenPackageW( szPackagePath, &package );
|
||||||
if (r != ERROR_SUCCESS)
|
if (r != ERROR_SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* copy the msi file to a temp file to pervent locking a CD
|
|
||||||
* with a multi disc install
|
|
||||||
*/
|
|
||||||
GetTempPathW(MAX_PATH, path);
|
|
||||||
GetTempFileNameW(path, szMSI, 0, filename);
|
|
||||||
|
|
||||||
CopyFileW(szPackagePath, filename, FALSE);
|
|
||||||
|
|
||||||
TRACE("Opening relocated package %s\n",debugstr_w(filename));
|
|
||||||
r = MSI_OpenPackageW(filename, &package);
|
|
||||||
if (r != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DeleteFileW(filename);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = alloc_msihandle( &package->hdr );
|
handle = alloc_msihandle( &package->hdr );
|
||||||
|
|
||||||
r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine,
|
r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine,
|
||||||
filename);
|
szPackagePath);
|
||||||
|
|
||||||
MsiCloseHandle(handle);
|
MsiCloseHandle(handle);
|
||||||
msiobj_release( &package->hdr );
|
msiobj_release( &package->hdr );
|
||||||
|
|
||||||
DeleteFileW(filename);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,6 +406,34 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* copy_package_to_temp [internal]
|
||||||
|
*
|
||||||
|
* copy the msi file to a temp file to prevent locking a CD
|
||||||
|
* with a multi disc install
|
||||||
|
*
|
||||||
|
* FIXME: I think this is wrong, and instead of copying the package,
|
||||||
|
* 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 )
|
||||||
|
{
|
||||||
|
WCHAR path[MAX_PATH];
|
||||||
|
static const WCHAR szMSI[] = {'M','S','I',0};
|
||||||
|
|
||||||
|
GetTempPathW( MAX_PATH, path );
|
||||||
|
GetTempFileNameW( path, szMSI, 0, filename );
|
||||||
|
|
||||||
|
if( !CopyFileW( szPackage, filename, FALSE ) )
|
||||||
|
{
|
||||||
|
ERR("failed to copy package to temp path %s\n", debugstr_w(filename) );
|
||||||
|
return szPackage;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Opening relocated package %s\n", debugstr_w( filename ));
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
||||||
{
|
{
|
||||||
MSIDATABASE *db = NULL;
|
MSIDATABASE *db = NULL;
|
||||||
|
@ -413,6 +441,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
||||||
MSIHANDLE handle;
|
MSIHANDLE handle;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
static const WCHAR szProductCode[]= {'P','r','o','d','u','c','t','C','o','d','e',0};
|
static const WCHAR szProductCode[]= {'P','r','o','d','u','c','t','C','o','d','e',0};
|
||||||
|
UINT r;
|
||||||
|
|
||||||
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
|
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
|
||||||
|
|
||||||
|
@ -425,7 +454,14 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UINT r = MSI_OpenDatabaseW(szPackage, MSIDBOPEN_READONLY, &db);
|
WCHAR temppath[MAX_PATH];
|
||||||
|
LPCWSTR file = copy_package_to_temp( szPackage, temppath );
|
||||||
|
|
||||||
|
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY, &db );
|
||||||
|
|
||||||
|
if (file != szPackage)
|
||||||
|
DeleteFileW( file );
|
||||||
|
|
||||||
if( r != ERROR_SUCCESS )
|
if( r != ERROR_SUCCESS )
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -466,40 +502,19 @@ UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phP
|
||||||
{
|
{
|
||||||
MSIPACKAGE *package = NULL;
|
MSIPACKAGE *package = NULL;
|
||||||
UINT ret;
|
UINT ret;
|
||||||
WCHAR path[MAX_PATH];
|
|
||||||
WCHAR filename[MAX_PATH];
|
|
||||||
static const WCHAR szMSI[] = {'M','S','I',0};
|
|
||||||
|
|
||||||
TRACE("%s %08lx %p\n",debugstr_w(szPackage), dwOptions, phPackage);
|
TRACE("%s %08lx %p\n", debugstr_w(szPackage), dwOptions, phPackage );
|
||||||
|
|
||||||
/* copy the msi file to a temp file to pervent locking a CD
|
|
||||||
* with a multi disc install
|
|
||||||
*/
|
|
||||||
if( szPackage[0] == '#' )
|
|
||||||
strcpyW(filename,szPackage);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetTempPathW(MAX_PATH, path);
|
|
||||||
GetTempFileNameW(path, szMSI, 0, filename);
|
|
||||||
|
|
||||||
CopyFileW(szPackage, filename, FALSE);
|
|
||||||
|
|
||||||
TRACE("Opening relocated package %s\n",debugstr_w(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
if( dwOptions )
|
if( dwOptions )
|
||||||
FIXME("dwOptions %08lx not supported\n", dwOptions);
|
FIXME("dwOptions %08lx not supported\n", dwOptions);
|
||||||
|
|
||||||
ret = MSI_OpenPackageW( filename, &package);
|
ret = MSI_OpenPackageW( szPackage, &package );
|
||||||
if( ret == ERROR_SUCCESS )
|
if( ret == ERROR_SUCCESS )
|
||||||
{
|
{
|
||||||
*phPackage = alloc_msihandle( &package->hdr );
|
*phPackage = alloc_msihandle( &package->hdr );
|
||||||
msiobj_release( &package->hdr );
|
msiobj_release( &package->hdr );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( szPackage[0] != '#' )
|
|
||||||
DeleteFileW(filename);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue