msi: Only run the CreateFolder and RemoveFolder actions when the component is set to be installed or removed, respectively.

This commit is contained in:
Hans Leidekker 2010-02-16 11:45:34 +01:00 committed by Alexandre Julliard
parent c32d9d7004
commit 9cbb80d984
2 changed files with 64 additions and 4 deletions

View File

@ -886,10 +886,24 @@ static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action,
static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
{ {
MSIPACKAGE *package = param; MSIPACKAGE *package = param;
LPCWSTR dir; LPCWSTR dir, component;
LPWSTR full_path; LPWSTR full_path;
MSIRECORD *uirow; MSIRECORD *uirow;
MSIFOLDER *folder; 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); dir = MSI_RecordGetString(row,1);
if (!dir) if (!dir)
@ -983,10 +997,24 @@ static UINT ACTION_CreateFolders(MSIPACKAGE *package)
static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param ) static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param )
{ {
MSIPACKAGE *package = param; MSIPACKAGE *package = param;
LPCWSTR dir; LPCWSTR dir, component;
LPWSTR full_path; LPWSTR full_path;
MSIRECORD *uirow; MSIRECORD *uirow;
MSIFOLDER *folder; 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 ); dir = MSI_RecordGetString( row, 1 );
if (!dir) if (!dir)

View File

@ -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" static const CHAR cf_create_folders_dat[] = "Directory_\tComponent_\n"
"s72\ts72\n" "s72\ts72\n"
"CreateFolder\tDirectory_\tComponent_\n" "CreateFolder\tDirectory_\tComponent_\n"
"MSITESTDIR\tOne\n"; "FIRSTDIR\tOne\n";
static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n" static const CHAR cf_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"s72\tS255\tI2\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\\filename", TRUE), "File installed\n");
ok(!delete_pf("msitest\\one.txt", 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\\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(); 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\\service.exe", TRUE), "File installed\n");
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(); delete_test_files();
} }