msi: Fix the conditions to determine which files to remove
James Hawkins
truiken at gmail.com
Mon Jun 18 17:44:07 CDT 2007
Hi,
This fixes an error with a test Windows Installer Patch that I'm
trying to get working.
Changelog:
* Fix the conditions to determine which files to remove.
dlls/msi/files.c | 7 +---
dlls/msi/tests/install.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 6 deletions(-)
--
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 42f954c..f86b20f 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -954,7 +954,7 @@ static int msi_compare_file_version( MSI
version[0] = '\0';
r = MsiGetFileVersionW( file->TargetPath, version, &size, NULL, NULL );
if ( r != ERROR_SUCCESS )
- return 0;
+ return -1; /* no version info, no match */
return lstrcmpW( version, file->Version );
}
@@ -970,13 +970,8 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *pac
if ( !file->Component )
continue;
- if ( file->Component->Installed == INSTALLSTATE_LOCAL )
- continue;
if ( file->state == msifs_installed )
- ERR("removing installed file %s\n", debugstr_w(file->TargetPath));
-
- if ( file->state != msifs_present )
continue;
/* only remove a file if the version to be installed
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
old mode 100644
new mode 100755
index ad4f35a..1fbce33
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -382,6 +382,25 @@ static const CHAR spf_install_ui_seq_dat
"CostFinalize\t\t1000\n"
"ExecuteAction\t\t1100\n";
+static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirProperty\tInstallMode\n"
+ "s72\ts72\tS255\ts72\tI2\n"
+ "RemoveFile\tFileKey\n"
+ "removefile\tmaximus\tmaximus\tMSITESTDIR\t1\n";
+
+static const CHAR rem_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
+ "s72\tS255\tI2\n"
+ "InstallExecuteSequence\tAction\n"
+ "AllocateRegistrySpace\tNOT Installed\t1550\n"
+ "CostFinalize\t\t1000\n"
+ "CostInitialize\t\t800\n"
+ "FileCost\t\t900\n"
+ "InstallFiles\tPART=1 Or PART=3\t4000\n"
+ "RemoveFiles\tPART=2 Or PART=3\t5000\n"
+ "InstallFinalize\t\t6600\n"
+ "InstallInitialize\t\t1500\n"
+ "InstallValidate\t\t1400\n"
+ "LaunchConditions\t\t100";
+
typedef struct _msi_table
{
const CHAR *filename;
@@ -556,6 +575,19 @@ static const msi_table spf_tables[] =
ADD_TABLE(spf_install_ui_seq),
};
+static const msi_table rem_tables[] =
+{
+ ADD_TABLE(rof_component),
+ ADD_TABLE(directory),
+ ADD_TABLE(rof_feature),
+ ADD_TABLE(rof_feature_comp),
+ ADD_TABLE(rof_file),
+ ADD_TABLE(rem_install_exec_seq),
+ ADD_TABLE(rof_media),
+ ADD_TABLE(property),
+ ADD_TABLE(rem_remove_files),
+};
+
/* cabinet definitions */
/* make the max size large so there is only one cab file */
@@ -1504,6 +1536,45 @@ static void test_setpropertyfolder(void)
RemoveDirectory("msitest");
}
+static BOOL file_exists(LPSTR file)
+{
+ return GetFileAttributes(file) != INVALID_FILE_ATTRIBUTES;
+}
+
+static void test_removefiles(void)
+{
+ UINT r;
+
+ CreateDirectoryA("msitest", NULL);
+ create_file("msitest\\maximus", 500);
+
+ create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
+
+ MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
+
+ r = MsiInstallProductA(msifile, "PART=1");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+ ok(file_exists("msitest\\maximus"), "File not installed\n");
+ ok(file_exists("msitest"), "File not installed\n");
+
+ r = MsiInstallProductA(msifile, "PART=2");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+ ok(!delete_pf("msitest\\maximus", TRUE), "File installed\n");
+ todo_wine
+ {
+ ok(!delete_pf("msitest", FALSE), "File installed\n");
+ }
+
+ r = MsiInstallProductA(msifile, "PART=3");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+ ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
+ ok(delete_pf("msitest", FALSE), "File not installed\n");
+
+ DeleteFile(msifile);
+ DeleteFile("msitest\\maximus");
+ RemoveDirectory("msitest");
+}
+
START_TEST(install)
{
DWORD len;
@@ -1534,6 +1605,7 @@ START_TEST(install)
test_cabisextracted();
test_concurrentinstall();
test_setpropertyfolder();
+ test_removefiles();
SetCurrentDirectoryA(prev_path);
}
--
1.4.1
More information about the wine-patches
mailing list