Commit 21836b79 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msi: Re-publish product if previous installation with different package is detected.

parent 6dc49e4b
......@@ -4473,6 +4473,7 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
UINT rc;
HKEY hukey = NULL, hudkey = NULL;
MSIRECORD *uirow;
BOOL republish = FALSE;
if (!list_empty(&package->patches))
{
......@@ -4481,14 +4482,49 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
goto end;
}
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, FALSE);
if (rc == ERROR_SUCCESS)
{
WCHAR *package_code;
package_code = msi_reg_get_val_str(hukey, INSTALLPROPERTY_PACKAGECODEW);
if (package_code)
{
WCHAR *guid;
guid = msi_get_package_code(package->db);
if (guid)
{
WCHAR packed[SQUASHED_GUID_SIZE];
squash_guid(guid, packed);
msi_free(guid);
if (!strcmpW(packed, package_code))
{
TRACE("re-publishing product - new package\n");
republish = TRUE;
}
}
msi_free(package_code);
}
}
/* FIXME: also need to publish if the product is in advertise mode */
if (!msi_check_publish(package))
if (!republish && !msi_check_publish(package))
{
if (hukey)
RegCloseKey(hukey);
return ERROR_SUCCESS;
}
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
if (!hukey)
{
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
&hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
}
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context,
NULL, &hudkey, TRUE);
......
......@@ -1048,6 +1048,7 @@ extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *) DEC
extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN;
extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote) DECLSPEC_HIDDEN;
extern UINT msi_strncpyW(const WCHAR *str, int len, WCHAR *buf, DWORD *sz) DECLSPEC_HIDDEN;
extern WCHAR *msi_get_package_code(MSIDATABASE *db) DECLSPEC_HIDDEN;
/* media */
......
......@@ -1385,7 +1385,7 @@ done:
return r;
}
static WCHAR *get_package_code( MSIDATABASE *db )
WCHAR *msi_get_package_code( MSIDATABASE *db )
{
WCHAR *ret;
MSISUMMARYINFO *si;
......@@ -1423,7 +1423,7 @@ static UINT get_local_package( const WCHAR *filename, WCHAR *localfile )
msiobj_release( &db->hdr );
return ERROR_INSTALL_PACKAGE_INVALID;
}
if (!(package_code = get_package_code( db )))
if (!(package_code = msi_get_package_code( db )))
{
msi_free( product_code );
msiobj_release( &db->hdr );
......
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