msi: Only remove a file if the version to be installed is strictly
newer than the old file
James Hawkins
truiken at gmail.com
Thu Aug 10 15:53:08 CDT 2006
Hi,
This fixes bug 4280 and makes the current tests pass.
http://bugs.winehq.org/show_bug.cgi?id=4280
Changelog:
* Only remove a file if the version to be installed is strictly newer
than the old file.
dlls/msi/files.c | 24 ++++++++++++++++++++++++
dlls/msi/tests/package.c | 11 ++++-------
2 files changed, 28 insertions(+), 7 deletions(-)
--
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 443e6c3..7f1c4db 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -823,6 +823,24 @@ UINT ACTION_DuplicateFiles(MSIPACKAGE *p
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;
@@ -843,6 +861,12 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *pac
if ( file->state != msifs_present )
continue;
+ /* only remove a file if the version to be installed
+ * is strictly newer than the old file
+ */
+ if ( msi_compare_file_version( file ) >= 0 )
+ continue;
+
TRACE("removing %s\n", debugstr_w(file->File) );
if ( !DeleteFileW( file->TargetPath ) )
ERR("failed to delete %s\n", debugstr_w(file->TargetPath) );
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 3ff7b0f..55b2e1c 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -1938,13 +1938,10 @@ static void test_removefiles(void)
r = MsiDoAction( hpkg, "RemoveFiles");
ok( r == ERROR_SUCCESS, "remove files failed\n");
- todo_wine
- {
- ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
- ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
- ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
- ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
- }
+ ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
+ ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
+ ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
+ ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
--
1.3.3
More information about the wine-patches
mailing list