From 9cbb80d984db6077a426182d29f62a1871b778ce Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 16 Feb 2010 11:45:34 +0100 Subject: [PATCH] msi: Only run the CreateFolder and RemoveFolder actions when the component is set to be installed or removed, respectively. --- dlls/msi/action.c | 32 ++++++++++++++++++++++++++++++-- dlls/msi/tests/install.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 7bb4e52f826..2c036b8648e 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -886,10 +886,24 @@ static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action, static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_LOCAL) + { + TRACE("Component not scheduled for installation: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_LOCAL; dir = MSI_RecordGetString(row,1); if (!dir) @@ -983,10 +997,24 @@ static UINT ACTION_CreateFolders(MSIPACKAGE *package) static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param ) { MSIPACKAGE *package = param; - LPCWSTR dir; + LPCWSTR dir, component; LPWSTR full_path; MSIRECORD *uirow; MSIFOLDER *folder; + MSICOMPONENT *comp; + + component = MSI_RecordGetString(row, 2); + comp = get_loaded_component(package, component); + if (!comp) + return ERROR_SUCCESS; + + if (comp->ActionRequest != INSTALLSTATE_ABSENT) + { + TRACE("Component not scheduled for removal: %s\n", debugstr_w(component)); + comp->Action = comp->Installed; + return ERROR_SUCCESS; + } + comp->Action = INSTALLSTATE_ABSENT; dir = MSI_RecordGetString( row, 1 ); if (!dir) diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index 8eb2b73ef65..44eec8e036e 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -1091,7 +1091,7 @@ static const CHAR aup_custom_action_dat[] = "Action\tType\tSource\tTarget\tISCom static const CHAR cf_create_folders_dat[] = "Directory_\tComponent_\n" "s72\ts72\n" "CreateFolder\tDirectory_\tComponent_\n" - "MSITESTDIR\tOne\n"; + "FIRSTDIR\tOne\n"; static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" "s72\tS255\tI2\n" @@ -7857,7 +7857,23 @@ static void test_create_folder(void) ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); - todo_wine ok(!delete_pf("msitest", FALSE), "Directory created\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); + + r = MsiInstallProductA(msifile, "LOCAL=Two"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\first", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); delete_test_files(); } @@ -7887,6 +7903,22 @@ static void test_remove_folder(void) ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); ok(!delete_pf("msitest", FALSE), "Directory created\n"); + r = MsiInstallProductA(msifile, "LOCAL=Two"); + ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %u\n", r); + + ok(!delete_pf("msitest\\cabout\\new\\five.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout\\new", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\cabout\\four.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\cabout", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\changed\\three.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\changed", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\first\\two.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\first", FALSE), "Directory created\n"); + ok(!delete_pf("msitest\\filename", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\one.txt", TRUE), "File installed\n"); + ok(!delete_pf("msitest\\service.exe", TRUE), "File installed\n"); + ok(!delete_pf("msitest", FALSE), "Directory created\n"); + delete_test_files(); }