msi: Remove local patch packages when the product is removed.

This commit is contained in:
Hans Leidekker 2011-08-23 14:42:03 +02:00 committed by Alexandre Julliard
parent 621b0405c9
commit 70e3790707
4 changed files with 41 additions and 22 deletions

View file

@ -4938,6 +4938,11 @@ static UINT msi_unpublish_product( MSIPACKAGE *package, const WCHAR *remove )
LIST_FOR_EACH_ENTRY(patch, &package->patches, MSIPATCHINFO, entry)
{
MSIREG_DeleteUserDataPatchKey(patch->patchcode, package->Context);
if (!strcmpW( package->ProductCode, patch->products ))
{
TRACE("removing local patch package %s\n", debugstr_w(patch->localfile));
patch->delete_on_close = TRUE;
}
/* FIXME: remove local patch package if this is the last product */
}
TRACE("removing local package %s\n", debugstr_w(package->localfile));

View file

@ -170,10 +170,12 @@ typedef struct tagMSIPATCHINFO
{
struct list entry;
LPWSTR patchcode;
LPWSTR products;
LPWSTR transforms;
LPWSTR filename;
LPWSTR localfile;
MSIPATCHSTATE state;
BOOL delete_on_close;
} MSIPATCHINFO;
typedef struct tagMSIBINARY
@ -770,6 +772,7 @@ extern UINT msi_apply_transforms( MSIPACKAGE *package ) DECLSPEC_HIDDEN;
extern UINT msi_check_patch_applicable( MSIPACKAGE *package, MSISUMMARYINFO *si ) DECLSPEC_HIDDEN;
extern UINT msi_apply_patches( MSIPACKAGE *package ) DECLSPEC_HIDDEN;
extern UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code ) DECLSPEC_HIDDEN;
extern void msi_free_patchinfo( MSIPATCHINFO *patch ) DECLSPEC_HIDDEN;
/* action internals */
extern UINT MSI_InstallPackage( MSIPACKAGE *, LPCWSTR, LPCWSTR ) DECLSPEC_HIDDEN;

View file

@ -293,18 +293,6 @@ static void free_package_structures( MSIPACKAGE *package )
msi_free( package->script );
}
LIST_FOR_EACH_SAFE( item, cursor, &package->patches )
{
MSIPATCHINFO *patch = LIST_ENTRY( item, MSIPATCHINFO, entry );
list_remove( &patch->entry );
msi_free( patch->patchcode );
msi_free( patch->transforms );
msi_free( patch->localfile );
msi_free( patch->filename );
msi_free( patch );
}
LIST_FOR_EACH_SAFE( item, cursor, &package->binaries )
{
MSIBINARY *binary = LIST_ENTRY( item, MSIBINARY, entry );
@ -329,6 +317,18 @@ static void free_package_structures( MSIPACKAGE *package )
msi_free( cab );
}
LIST_FOR_EACH_SAFE( item, cursor, &package->patches )
{
MSIPATCHINFO *patch = LIST_ENTRY( item, MSIPATCHINFO, entry );
list_remove( &patch->entry );
if (patch->delete_on_close && !DeleteFileW( patch->localfile ))
{
ERR("failed to delete %s (%u)\n", debugstr_w(patch->localfile), GetLastError());
}
msi_free_patchinfo( patch );
}
msi_free( package->BaseURL );
msi_free( package->PackagePath );
msi_free( package->ProductCode );

View file

@ -184,10 +184,16 @@ static UINT msi_parse_patch_summary( MSISUMMARYINFO *si, MSIPATCHINFO **patch )
p[1] = 0;
}
TRACE("patch code %s\n", debugstr_w(pi->patchcode));
if (!(pi->products = msi_suminfo_dup_string( si, PID_TEMPLATE )))
{
msi_free( pi->patchcode );
msi_free( pi );
return ERROR_OUTOFMEMORY;
}
if (!(pi->transforms = msi_suminfo_dup_string( si, PID_LASTAUTHOR )))
{
msi_free( pi->patchcode );
msi_free( pi->products );
msi_free( pi );
return ERROR_OUTOFMEMORY;
}
@ -597,6 +603,16 @@ static UINT msi_apply_patch_db( MSIPACKAGE *package, MSIDATABASE *patch_db, MSIP
return ERROR_SUCCESS;
}
void msi_free_patchinfo( MSIPATCHINFO *patch )
{
msi_free( patch->patchcode );
msi_free( patch->products );
msi_free( patch->transforms );
msi_free( patch->filename );
msi_free( patch->localfile );
msi_free( patch );
}
static UINT msi_apply_patch_package( MSIPACKAGE *package, const WCHAR *file )
{
static const WCHAR dotmsp[] = {'.','m','s','p',0};
@ -646,11 +662,8 @@ done:
msiobj_release( &patch_db->hdr );
if (patch && r != ERROR_SUCCESS)
{
msi_free( patch->patchcode );
msi_free( patch->transforms );
msi_free( patch->filename );
msi_free( patch->localfile );
msi_free( patch );
DeleteFileW( patch->localfile );
msi_free_patchinfo( patch );
}
return r;
}
@ -756,6 +769,7 @@ UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code )
if (!patch_info->localfile)
{
msiobj_release( &patch_db->hdr );
msi_free_patchinfo( patch_info );
return ERROR_OUTOFMEMORY;
}
r = msi_apply_patch_db( package, patch_db, patch_info );
@ -763,10 +777,7 @@ UINT msi_apply_registered_patch( MSIPACKAGE *package, LPCWSTR patch_code )
if (r != ERROR_SUCCESS)
{
ERR("failed to apply patch %u\n", r);
msi_free( patch_info->patchcode );
msi_free( patch_info->transforms );
msi_free( patch_info->localfile );
msi_free( patch_info );
msi_free_patchinfo( patch_info );
}
return r;
}