Commit 99aa0eb5 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Don't cache the base URL.

parent 1b88ec9c
...@@ -4113,7 +4113,7 @@ static MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE *db ) ...@@ -4113,7 +4113,7 @@ static MSIPREVIEW *MSI_EnableUIPreview( MSIDATABASE *db )
MSIPREVIEW *preview = NULL; MSIPREVIEW *preview = NULL;
MSIPACKAGE *package; MSIPACKAGE *package;
package = MSI_CreatePackage( db, NULL ); package = MSI_CreatePackage( db );
if (package) if (package)
{ {
preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof(MSIPREVIEW), MSI_ClosePreview ); preview = alloc_msiobject( MSIHANDLETYPE_PREVIEW, sizeof(MSIPREVIEW), MSI_ClosePreview );
......
...@@ -678,6 +678,14 @@ static UINT get_drive_type(const WCHAR *path) ...@@ -678,6 +678,14 @@ static UINT get_drive_type(const WCHAR *path)
return GetDriveTypeW(root); return GetDriveTypeW(root);
} }
static WCHAR *get_base_url( MSIDATABASE *db )
{
WCHAR *p, *ret = NULL, *orig_db = msi_dup_property( db, szOriginalDatabase );
if (UrlIsW( orig_db, URLIS_URL ) && (ret = strdupW( orig_db )) && (p = strrchrW( ret, '/'))) p[1] = 0;
msi_free( orig_db );
return ret;
}
UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi)
{ {
static const WCHAR query[] = { static const WCHAR query[] = {
...@@ -685,7 +693,7 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) ...@@ -685,7 +693,7 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi)
'W','H','E','R','E',' ','`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ','`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ',
'>','=',' ','%','i',' ','O','R','D','E','R',' ','B','Y',' ','`','D','i','s','k','I','d','`',0}; '>','=',' ','%','i',' ','O','R','D','E','R',' ','B','Y',' ','`','D','i','s','k','I','d','`',0};
MSIRECORD *row; MSIRECORD *row;
LPWSTR source_dir, source; WCHAR *source_dir, *source, *base_url = NULL;
DWORD options; DWORD options;
if (Sequence <= mi->last_sequence) /* already loaded */ if (Sequence <= mi->last_sequence) /* already loaded */
...@@ -721,9 +729,9 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) ...@@ -721,9 +729,9 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi)
source = source_dir; source = source_dir;
options |= MSISOURCETYPE_MEDIA; options |= MSISOURCETYPE_MEDIA;
} }
else if (package->BaseURL && UrlIsW(package->BaseURL, URLIS_URL)) else if ((base_url = get_base_url(package->db)))
{ {
source = package->BaseURL; source = base_url;
options |= MSISOURCETYPE_URL; options |= MSISOURCETYPE_URL;
} }
else else
...@@ -739,8 +747,10 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi) ...@@ -739,8 +747,10 @@ UINT msi_load_media_info(MSIPACKAGE *package, UINT Sequence, MSIMEDIAINFO *mi)
msi_package_add_info(package, package->Context, msi_package_add_info(package, package->Context,
options, INSTALLPROPERTY_LASTUSEDSOURCEW, source); options, INSTALLPROPERTY_LASTUSEDSOURCEW, source);
msi_free(source_dir);
TRACE("sequence %u -> cabinet %s disk id %u\n", Sequence, debugstr_w(mi->cabinet), mi->disk_id); TRACE("sequence %u -> cabinet %s disk id %u\n", Sequence, debugstr_w(mi->cabinet), mi->disk_id);
msi_free(base_url);
msi_free(source_dir);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
...@@ -851,6 +861,8 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi ) ...@@ -851,6 +861,8 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi )
if (mi->cabinet) if (mi->cabinet)
{ {
WCHAR *base_url;
/* cabinet is internal, no checks needed */ /* cabinet is internal, no checks needed */
if (mi->cabinet[0] == '#') return ERROR_SUCCESS; if (mi->cabinet[0] == '#') return ERROR_SUCCESS;
...@@ -858,14 +870,21 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi ) ...@@ -858,14 +870,21 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi )
/* package should be downloaded */ /* package should be downloaded */
if (compressed && GetFileAttributesW( cabinet_file ) == INVALID_FILE_ATTRIBUTES && if (compressed && GetFileAttributesW( cabinet_file ) == INVALID_FILE_ATTRIBUTES &&
package->BaseURL && UrlIsW( package->BaseURL, URLIS_URL )) (base_url = get_base_url( package->db )))
{ {
WCHAR temppath[MAX_PATH], *p; WCHAR temppath[MAX_PATH], *p, *url;
if ((rc = msi_download_file( cabinet_file, temppath )) != ERROR_SUCCESS) msi_free( cabinet_file );
if (!(url = msi_alloc( (strlenW( base_url ) + strlenW( mi->cabinet ) + 1) * sizeof(WCHAR) )))
{ {
ERR("failed to download %s (%u)\n", debugstr_w(cabinet_file), rc); return ERROR_OUTOFMEMORY;
msi_free( cabinet_file ); }
strcpyW( url, base_url );
strcatW( url, mi->cabinet );
if ((rc = msi_download_file( url, temppath )) != ERROR_SUCCESS)
{
ERR("failed to download %s (%u)\n", debugstr_w(url), rc);
msi_free( url );
return rc; return rc;
} }
if ((p = strrchrW( temppath, '\\' ))) *p = 0; if ((p = strrchrW( temppath, '\\' ))) *p = 0;
...@@ -873,7 +892,8 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi ) ...@@ -873,7 +892,8 @@ UINT ready_media( MSIPACKAGE *package, BOOL compressed, MSIMEDIAINFO *mi )
PathAddBackslashW( mi->sourcedir ); PathAddBackslashW( mi->sourcedir );
msi_free( mi->cabinet ); msi_free( mi->cabinet );
mi->cabinet = strdupW( p + 1 ); mi->cabinet = strdupW( p + 1 );
msi_free( cabinet_file );
msi_free( url );
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
} }
......
...@@ -424,7 +424,6 @@ typedef struct tagMSIPACKAGE ...@@ -424,7 +424,6 @@ typedef struct tagMSIPACKAGE
struct list RunningActions; struct list RunningActions;
LPWSTR BaseURL;
LPWSTR PackagePath; LPWSTR PackagePath;
LPWSTR ProductCode; LPWSTR ProductCode;
LPWSTR localfile; LPWSTR localfile;
...@@ -861,7 +860,7 @@ extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **) DECLS ...@@ -861,7 +860,7 @@ extern UINT msi_view_get_row(MSIDATABASE *, MSIVIEW *, UINT, MSIRECORD **) DECLS
extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel ) DECLSPEC_HIDDEN; extern UINT MSI_SetInstallLevel( MSIPACKAGE *package, int iInstallLevel ) DECLSPEC_HIDDEN;
/* package internals */ /* package internals */
extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *, LPCWSTR ) DECLSPEC_HIDDEN; extern MSIPACKAGE *MSI_CreatePackage( MSIDATABASE * ) DECLSPEC_HIDDEN;
extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage ) DECLSPEC_HIDDEN; extern UINT MSI_OpenPackageW( LPCWSTR szPackage, MSIPACKAGE **pPackage ) DECLSPEC_HIDDEN;
extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR ) DECLSPEC_HIDDEN; extern UINT MSI_SetTargetPathW( MSIPACKAGE *, LPCWSTR, LPCWSTR ) DECLSPEC_HIDDEN;
extern INT MSI_ProcessMessageVerbatim( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * ) DECLSPEC_HIDDEN; extern INT MSI_ProcessMessageVerbatim( MSIPACKAGE *, INSTALLMESSAGE, MSIRECORD * ) DECLSPEC_HIDDEN;
......
...@@ -321,7 +321,6 @@ static void free_package_structures( MSIPACKAGE *package ) ...@@ -321,7 +321,6 @@ static void free_package_structures( MSIPACKAGE *package )
msi_free_patchinfo( patch ); msi_free_patchinfo( patch );
} }
msi_free( package->BaseURL );
msi_free( package->PackagePath ); msi_free( package->PackagePath );
msi_free( package->ProductCode ); msi_free( package->ProductCode );
msi_free( package->ActionFormat ); msi_free( package->ActionFormat );
...@@ -1056,7 +1055,7 @@ void msi_adjust_privilege_properties( MSIPACKAGE *package ) ...@@ -1056,7 +1055,7 @@ void msi_adjust_privilege_properties( MSIPACKAGE *package )
msi_set_property( package->db, szAdminUser, szOne, -1 ); msi_set_property( package->db, szAdminUser, szOne, -1 );
} }
MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url ) MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
{ {
static const WCHAR fmtW[] = {'%','u',0}; static const WCHAR fmtW[] = {'%','u',0};
MSIPACKAGE *package; MSIPACKAGE *package;
...@@ -1077,7 +1076,6 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url ) ...@@ -1077,7 +1076,6 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
package->LastActionResult = MSI_NULL_INTEGER; package->LastActionResult = MSI_NULL_INTEGER;
package->WordCount = 0; package->WordCount = 0;
package->PackagePath = strdupW( db->path ); package->PackagePath = strdupW( db->path );
package->BaseURL = strdupW( base_url );
create_temp_property_table( package ); create_temp_property_table( package );
msi_clone_properties( package->db ); msi_clone_properties( package->db );
...@@ -1447,15 +1445,13 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) ...@@ -1447,15 +1445,13 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
MSIPACKAGE *package; MSIPACKAGE *package;
MSIHANDLE handle; MSIHANDLE handle;
MSIRECORD *data_row, *info_row; MSIRECORD *data_row, *info_row;
LPWSTR ptr, base_url = NULL;
UINT r; UINT r;
WCHAR localfile[MAX_PATH], cachefile[MAX_PATH]; WCHAR localfile[MAX_PATH], cachefile[MAX_PATH];
LPCWSTR file = szPackage; LPCWSTR file = szPackage;
DWORD index = 0; DWORD index = 0;
MSISUMMARYINFO *si; MSISUMMARYINFO *si;
BOOL delete_on_close = FALSE; BOOL delete_on_close = FALSE;
LPWSTR productname; WCHAR *info_template, *productname;
WCHAR *info_template;
TRACE("%s %p\n", debugstr_w(szPackage), pPackage); TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
...@@ -1487,30 +1483,19 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) ...@@ -1487,30 +1483,19 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
return r; return r;
file = cachefile; file = cachefile;
base_url = strdupW( szPackage );
if (!base_url)
return ERROR_OUTOFMEMORY;
ptr = strrchrW( base_url, '/' );
if (ptr) *(ptr + 1) = '\0';
} }
r = get_local_package( file, localfile ); r = get_local_package( file, localfile );
if (r != ERROR_SUCCESS || GetFileAttributesW( localfile ) == INVALID_FILE_ATTRIBUTES) if (r != ERROR_SUCCESS || GetFileAttributesW( localfile ) == INVALID_FILE_ATTRIBUTES)
{ {
r = msi_create_empty_local_file( localfile, dotmsi ); r = msi_create_empty_local_file( localfile, dotmsi );
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{
msi_free ( base_url );
return r; return r;
}
if (!CopyFileW( file, localfile, FALSE )) if (!CopyFileW( file, localfile, FALSE ))
{ {
r = GetLastError(); r = GetLastError();
WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file), debugstr_w(localfile), r); WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file), debugstr_w(localfile), r);
DeleteFileW( localfile ); DeleteFileW( localfile );
msi_free ( base_url );
return r; return r;
} }
delete_on_close = TRUE; delete_on_close = TRUE;
...@@ -1518,13 +1503,9 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage) ...@@ -1518,13 +1503,9 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
TRACE("opening package %s\n", debugstr_w( localfile )); TRACE("opening package %s\n", debugstr_w( localfile ));
r = MSI_OpenDatabaseW( localfile, MSIDBOPEN_TRANSACT, &db ); r = MSI_OpenDatabaseW( localfile, MSIDBOPEN_TRANSACT, &db );
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
{
msi_free ( base_url );
return r; return r;
}
} }
package = MSI_CreatePackage( db, base_url ); package = MSI_CreatePackage( db );
msi_free( base_url );
msiobj_release( &db->hdr ); msiobj_release( &db->hdr );
if (!package) return ERROR_INSTALL_PACKAGE_INVALID; if (!package) return ERROR_INSTALL_PACKAGE_INVALID;
package->localfile = strdupW( localfile ); package->localfile = strdupW( localfile );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment