James Hawkins : msi: Don' t overwrite a file that has a greater or equal version to the source file.

Alexandre Julliard julliard at winehq.org
Wed Jun 25 16:44:04 CDT 2008


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

Author: James Hawkins <truiken at gmail.com>
Date:   Mon Jun 23 23:41:22 2008 -0500

msi: Don't overwrite a file that has a greater or equal version to the source file.

---

 dlls/msi/files.c |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index c6e70d9..08c1959 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -459,6 +459,24 @@ done:
     return ret;
 }
 
+/* compares the version of a file read from the filesystem and
+ * the version specified in the File table
+ */
+static int msi_compare_file_version(MSIFILE *file)
+{
+    WCHAR version[MAX_PATH];
+    DWORD size;
+    UINT r;
+
+    size = MAX_PATH;
+    version[0] = '\0';
+    r = MsiGetFileVersionW(file->TargetPath, version, &size, NULL, NULL);
+    if (r != ERROR_SUCCESS)
+        return 0;
+
+    return lstrcmpW(version, file->Version);
+}
+
 void msi_free_media_info( MSIMEDIAINFO *mi )
 {
     msi_free( mi->disk_prompt );
@@ -802,6 +820,13 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package)
             continue;
         }
 
+        if (MsiGetFileVersionW(file->TargetPath, NULL, NULL, NULL, NULL) == ERROR_SUCCESS &&
+            msi_compare_file_version(file) >= 0)
+        {
+            TRACE("Destination file version greater, not overwriting\n");
+            continue;
+        }
+
         if (file->Sequence > mi->last_sequence || mi->is_continuous ||
             (file->IsCompressed && !mi->is_extracted))
         {
@@ -972,24 +997,6 @@ UINT ACTION_DuplicateFiles(MSIPACKAGE *package)
     return rc;
 }
 
-/* compares the version of a file read from the filesystem and
- * the version specified in the File table
- */
-static int msi_compare_file_version( MSIFILE *file )
-{
-    WCHAR version[MAX_PATH];
-    DWORD size;
-    UINT r;
-
-    size = MAX_PATH;
-    version[0] = '\0';
-    r = MsiGetFileVersionW( file->TargetPath, version, &size, NULL, NULL );
-    if ( r != ERROR_SUCCESS )
-        return 0;
-
-    return lstrcmpW( version, file->Version );
-}
-
 UINT ACTION_RemoveFiles( MSIPACKAGE *package )
 {
     MSIFILE *file;




More information about the wine-cvs mailing list