[MSI 4/4] Force files' target paths recompute on MsiSetTargetPath

Andrey Turkin pancha at mail.nnov.ru
Mon Jun 19 11:47:45 CDT 2006


When folder's target path changes, files' target paths should be updated
too. However, Wine don't flush any cached target paths, so files would
be installed in incorrect directories. This patch fixes it.

ChangeLog:
Force files' target paths update on MsiSetTargetPath
-------------- next part --------------
--- wine-0.9.15-orig/dlls/msi/helpers.c	2006-06-19 19:45:25.000000000 +0400
+++ wine-0.9.15/dlls/msi/helpers.c	2006-06-19 20:17:06.000000000 +0400
@@ -278,29 +278,13 @@
     if (!name)
         return NULL;
 
-    /* special resolving for Target and Source root dir */
-    if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
+    /* special resolving for Source root dir */
+    if ( strcmpW(name,cszSourceDir)==0)
     {
-        if (!source)
-        {
-            LPWSTR check_path;
-            check_path = msi_dup_property( package, cszTargetDir );
-            if (!check_path)
-            {
-                check_path = msi_dup_property( package, cszRootDrive );
-                if (set_prop)
-                    MSI_SetPropertyW(package,cszTargetDir,check_path);
-            }
-
-            /* correct misbuilt target dir */
-            path = build_directory_name(2, check_path, NULL);
-            clean_spaces_from_path( path );
-            if (strcmpiW(path,check_path)!=0)
-                MSI_SetPropertyW(package,cszTargetDir,path);
-            msi_free(check_path);
-        }
-        else
+        if (source)
             path = get_source_root( package );
+        else
+            path = NULL;
         if (folder)
             *folder = get_loaded_folder( package, name );
         return path;
@@ -313,6 +297,11 @@
     if (folder)
         *folder = f;
 
+    if (strcmpW(name, cszTargetDir)==0 && !f->ResolvedTarget && !f->Property)
+    {
+        f->Property =  msi_dup_property( package, cszRootDrive );
+    }
+
     if (!source && f->ResolvedTarget)
     {
         path = strdupW( f->ResolvedTarget );
--- wine-0.9.15-orig/dlls/msi/install.c	2006-06-19 20:11:05.000000000 +0400
+++ wine-0.9.15/dlls/msi/install.c	2006-06-19 20:11:36.000000000 +0400
@@ -362,6 +362,7 @@
     else
     {
         MSIFOLDER *f;
+        MSIFILE *file; 
 
         LIST_FOR_EACH_ENTRY( f, &package->folders, MSIFOLDER, entry )
         {
@@ -374,6 +375,28 @@
             path2 = resolve_folder(package, f->Directory, FALSE, TRUE, NULL);
             msi_free(path2);
         }
+
+        LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
+        {
+            MSICOMPONENT* comp = file->Component;
+            LPWSTR p;
+            
+            if (!comp)
+                continue;
+            
+            /* FIXME: do not reset file target path if component directory hasn't changed */
+            
+            p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL);
+            
+            msi_free(file->TargetPath);
+            file->TargetPath = build_directory_name(2, p, file->FileName);
+
+            msi_free(p);
+
+            if (GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
+                file->state = msifs_missing;
+            /* I don't know what else should be done in case of changed target path */
+        }
     }
     msi_free(path);
 
--- wine-0.9.15-orig/dlls/msi/tests/package.c	2006-06-19 20:11:05.000000000 +0400
+++ wine-0.9.15/dlls/msi/tests/package.c	2006-06-19 20:18:42.000000000 +0400
@@ -497,9 +497,7 @@
         r = get_file_targetpath(hpkg, "[#FL_TestFile]", filebuffer, sizeof filebuffer-1 );
         ok( r == S_OK, "get_file_targetpath failed\n" );
 
-        todo_wine {
         ok( strcmp(filebuffer, buffer) == 0, "directories differ: dir path: '%s', file path: '%s'\n", buffer, filebuffer );
-        }
 
         r = GetFileAttributes( buffer );
         ok ( r == 0xFFFFFFFF, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );


More information about the wine-patches mailing list