MSI: track less tempfiles in custom actions

Aric Stewart aric at codeweavers.com
Thu Jun 16 10:00:48 CDT 2005


a simple cleanup to only track the temp file if we need to have it laying around because the action is going on asynchronously. Otherwise clean up the temp file as the action finishes. Prevents polluting our file list with alot of unneeded temporary files and also keeps leftover files on a failure to clean up properly down to a minimum.

-------------- next part --------------
Index: dlls/msi/custom.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/custom.c,v
retrieving revision 1.15
diff -u -r1.15 custom.c
--- dlls/msi/custom.c	2 Jun 2005 10:29:57 -0000	1.15
+++ dlls/msi/custom.c	16 Jun 2005 14:58:56 -0000
@@ -213,9 +213,6 @@
         HANDLE the_file;
         CHAR buffer[1024];
 
-        if (track_tempfile(package, tmp_file, tmp_file)!=0)
-            FIXME("File Name in temp tracking collision\n");
-
         the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
                            FILE_ATTRIBUTE_NORMAL, NULL);
     
@@ -303,7 +300,7 @@
 
 static UINT process_handle(MSIPACKAGE* package, UINT type, 
                            HANDLE ThreadHandle, HANDLE ProcessHandle,
-                           LPCWSTR Name)
+                           LPCWSTR Name, BOOL *finished)
 {
     UINT rc = ERROR_SUCCESS;
 
@@ -327,6 +324,8 @@
         CloseHandle(ThreadHandle);
         if (ProcessHandle);
             CloseHandle(ProcessHandle);
+        if (finished)
+            *finished = TRUE;
     }
     else 
     {
@@ -348,6 +347,8 @@
             if (ProcessHandle);
                 CloseHandle(ProcessHandle);
         }
+        if (finished)
+            *finished = FALSE;
     }
 
     return rc;
@@ -433,6 +434,7 @@
     DWORD ThreadId;
     HANDLE ThreadHandle;
     UINT rc = ERROR_SUCCESS;
+    BOOL finished = FALSE;
 
     store_binary_to_temp(package, source, tmp_file);
 
@@ -453,7 +455,12 @@
 
     ThreadHandle = CreateThread(NULL,0,DllThread,(LPVOID)info,0,&ThreadId);
 
-    rc = process_handle(package, type, ThreadHandle, NULL, action);
+    rc = process_handle(package, type, ThreadHandle, NULL, action, &finished );
+
+    if (!finished)
+        track_tempfile(package, tmp_file, tmp_file);
+    else
+        DeleteFileW(tmp_file);
  
     return rc;
 }
@@ -470,6 +477,7 @@
     WCHAR *cmd;
     static const WCHAR spc[] = {' ',0};
     UINT prc = ERROR_SUCCESS;
+    BOOL finished = FALSE;
 
     memset(&si,0,sizeof(STARTUPINFOW));
 
@@ -506,8 +514,14 @@
         return ERROR_SUCCESS;
     }
 
-    prc = process_handle(package, type, info.hThread, info.hProcess, action);
+    prc = process_handle(package, type, info.hThread, info.hProcess, action, 
+                          &finished);
 
+    if (!finished)
+        track_tempfile(package, tmp_file, tmp_file);
+    else
+        DeleteFileW(tmp_file);
+    
     return prc;
 }
 
@@ -559,7 +573,8 @@
         return ERROR_SUCCESS;
     }
 
-    prc = process_handle(package, type, info.hThread, info.hProcess, action);
+    prc = process_handle(package, type, info.hThread, info.hProcess, action, 
+                         NULL);
 
     return prc;
 }
@@ -643,7 +658,8 @@
         return ERROR_SUCCESS;
     }
 
-    prc = process_handle(package, type, info.hThread, info.hProcess, action);
+    prc = process_handle(package, type, info.hThread, info.hProcess, action, 
+                         NULL);
 
     return prc;
 }
@@ -684,7 +700,8 @@
         return ERROR_SUCCESS;
     }
 
-    prc = process_handle(package, type, info.hThread, info.hProcess, action);
+    prc = process_handle(package, type, info.hThread, info.hProcess, action,
+                         NULL);
 
     return prc;
 }


More information about the wine-patches mailing list