Sync to trunk head (r47736)
[reactos.git] / dll / win32 / msi / upgrade.c
index a440070..b131d66 100644 (file)
@@ -61,8 +61,9 @@ static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
     LPWSTR prop;
     LPWSTR newprop;
     DWORD len;
+    UINT r;
 
-    prop = msi_dup_property(package, action_property );
+    prop = msi_dup_property(package->db, action_property );
     if (prop)
         len = strlenW(prop);
     else
@@ -87,9 +88,13 @@ static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
         newprop[0] = 0;
     strcatW(newprop,productid);
 
-    MSI_SetPropertyW(package, action_property, newprop);
-    TRACE("Found Related Product... %s now %s\n",debugstr_w(action_property),
-                    debugstr_w(newprop));
+    r = msi_set_property( package->db, action_property, newprop );
+    if (r == ERROR_SUCCESS && !strcmpW( action_property, cszSourceDir ))
+        msi_reset_folders( package, TRUE );
+
+    TRACE("Found Related Product... %s now %s\n",
+          debugstr_w(action_property), debugstr_w(newprop));
+
     msi_free( prop );
     msi_free( newprop );
 }
@@ -146,26 +151,30 @@ static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
                     (LPBYTE)&check, &sz);
             /* check min */
             ver = MSI_RecordGetString(rec,2);
-            comp_ver = msi_version_str_to_dword(ver);
-            r = check - comp_ver; 
-            if (r < 0 || (r == 0 && !(attributes &
-                                    msidbUpgradeAttributesVersionMinInclusive)))
+            if (ver)
             {
-                RegCloseKey(hukey);
-                index ++;
-                continue;
+                comp_ver = msi_version_str_to_dword(ver);
+                r = check - comp_ver;
+                if (r < 0 || (r == 0 && !(attributes & msidbUpgradeAttributesVersionMinInclusive)))
+                {
+                    RegCloseKey(hukey);
+                    index ++;
+                    continue;
+                }
             }
 
             /* check max */
             ver = MSI_RecordGetString(rec,3);
-            comp_ver = msi_version_str_to_dword(ver);
-            r = check - comp_ver;
-            if (r > 0 || (r == 0 && !(attributes & 
-                                    msidbUpgradeAttributesVersionMaxInclusive)))
+            if (ver)
             {
-                RegCloseKey(hukey);
-                index ++;
-                continue;
+                comp_ver = msi_version_str_to_dword(ver);
+                r = check - comp_ver;
+                if (r > 0 || (r == 0 && !(attributes & msidbUpgradeAttributesVersionMaxInclusive)))
+                {
+                    RegCloseKey(hukey);
+                    index ++;
+                    continue;
+                }
             }
 
             /* check language*/
@@ -203,19 +212,19 @@ UINT ACTION_FindRelatedProducts(MSIPACKAGE *package)
     UINT rc = ERROR_SUCCESS;
     MSIQUERY *view;
 
-    if (msi_get_property_int(package, szInstalled, 0))
+    if (msi_get_property_int(package->db, szInstalled, 0))
     {
         TRACE("Skipping FindRelatedProducts action: product already installed\n");
         return ERROR_SUCCESS;
     }
 
-    if (check_unique_action(package,szFindRelatedProducts))
+    if (check_unique_action(package, szFindRelatedProducts))
     {
-        TRACE("Skipping FindRelatedProducts action: already done on client side\n");
+        TRACE("Skipping FindRelatedProducts action: already done in UI sequence\n");
         return ERROR_SUCCESS;
     }
     else
-        register_unique_action(package,szFindRelatedProducts);
+        register_unique_action(package, szFindRelatedProducts);
 
     rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
     if (rc != ERROR_SUCCESS)