Mike McCormack : msi: Only apply transforms that are valid for a database.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Oct 23 06:14:50 CDT 2006


Module: wine
Branch: master
Commit: 0d7dc8f98ddabc39deff7e409581ae4baaa66f03
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0d7dc8f98ddabc39deff7e409581ae4baaa66f03

Author: Mike McCormack <mike at codeweavers.com>
Date:   Tue Oct 24 01:12:13 2006 +0900

msi: Only apply transforms that are valid for a database.

---

 dlls/msi/action.c  |   31 ++++++++++++++++++++++++++++---
 dlls/msi/msipriv.h |    1 +
 dlls/msi/suminfo.c |   16 ++++++++++++++++
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 9205884..66504e8 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -398,6 +398,28 @@ static LPWSTR* msi_split_string( LPCWSTR
     return ret;
 }
 
+static UINT msi_check_transform_applicable( MSIPACKAGE *package, IStorage *patch )
+{
+    WCHAR szProductCode[] = { 'P','r','o','d','u','c','t','C','o','d','e',0 };
+    LPWSTR prod_code, patch_product;
+    UINT ret;
+
+    prod_code = msi_dup_property( package, szProductCode );
+    patch_product = msi_get_suminfo_product( patch );
+
+    TRACE("db = %s patch = %s\n", debugstr_w(prod_code), debugstr_w(patch_product));
+
+    if ( strstrW( patch_product, prod_code ) )
+        ret = ERROR_SUCCESS;
+    else
+        ret = ERROR_FUNCTION_FAILED;
+
+    msi_free( patch_product );
+    msi_free( prod_code );
+
+    return ret;
+}
+
 static UINT msi_apply_substorage_transform( MSIPACKAGE *package,
                                  MSIDATABASE *patch_db, LPCWSTR name )
 {
@@ -416,14 +438,17 @@ static UINT msi_apply_substorage_transfo
     r = IStorage_OpenStorage( patch_db->storage, name, NULL, STGM_SHARE_EXCLUSIVE, NULL, 0, &stg );
     if (SUCCEEDED(r))
     {
-        ret = msi_table_apply_transform( package->db, stg );
+        ret = msi_check_transform_applicable( package, stg );
+        if (ret == ERROR_SUCCESS)
+            msi_table_apply_transform( package->db, stg );
+        else
+            TRACE("substorage transform %s wasn't applicable\n", debugstr_w(name));
         IStorage_Release( stg );
-        ret = ERROR_SUCCESS;
     }
     else
         ERR("failed to open substorage %s\n", debugstr_w(name));
 
-    return ret;
+    return ERROR_SUCCESS;
 }
 
 static UINT msi_check_patch_applicable( MSIPACKAGE *package, MSISUMMARYINFO *si )
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 5fe45f6..5acdd25 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -688,6 +688,7 @@ extern UINT MSI_PreviewDialogW( MSIPREVI
 /* summary information */
 extern MSISUMMARYINFO *MSI_GetSummaryInformationW( IStorage *stg, UINT uiUpdateCount );
 extern LPWSTR msi_suminfo_dup_string( MSISUMMARYINFO *si, UINT uiProperty );
+extern LPWSTR msi_get_suminfo_product( IStorage *stg );
 
 /* undocumented functions */
 UINT WINAPI MsiCreateAndVerifyInstallerDirectory( DWORD );
diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c
index 44bcbf4..f7f5787 100644
--- a/dlls/msi/suminfo.c
+++ b/dlls/msi/suminfo.c
@@ -602,6 +602,22 @@ LPWSTR msi_suminfo_dup_string( MSISUMMAR
     return strdupAtoW( prop->u.pszVal );
 }
 
+LPWSTR msi_get_suminfo_product( IStorage *stg )
+{
+    MSISUMMARYINFO *si;
+    LPWSTR prod;
+
+    si = MSI_GetSummaryInformationW( stg, 0 );
+    if (!si)
+    {
+        ERR("no summary information!\n");
+        return NULL;
+    }
+    prod = msi_suminfo_dup_string( si, PID_REVNUMBER );
+    msiobj_release( &si->hdr );
+    return prod;
+}
+
 UINT WINAPI MsiSummaryInfoGetPropertyA(
       MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
       FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)




More information about the wine-cvs mailing list