msi: Remove empty directories as part of the RemoveFiles action.

This commit is contained in:
Hans Leidekker 2010-02-26 14:09:02 +01:00 committed by Alexandre Julliard
parent 9f303c8942
commit fd5887e5a9
2 changed files with 39 additions and 54 deletions

View File

@ -597,11 +597,10 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param)
goto done;
}
lstrcpyW(path, dir);
PathAddBackslashW(path);
if (filename)
{
lstrcpyW(path, dir);
PathAddBackslashW(path);
lstrcatW(path, filename);
TRACE("Deleting misc file: %s\n", debugstr_w(path));
@ -609,8 +608,8 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param)
}
else
{
TRACE("Removing misc directory: %s\n", debugstr_w(path));
RemoveDirectoryW(path);
TRACE("Removing misc directory: %s\n", debugstr_w(dir));
RemoveDirectoryW(dir);
}
done:
@ -628,6 +627,9 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package )
static const WCHAR query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','R','e','m','o','v','e','F','i','l','e','`',0};
static const WCHAR folder_query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
r = MSI_DatabaseOpenViewW(package->db, query, &view);
if (r == ERROR_SUCCESS)
@ -636,10 +638,14 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package )
msiobj_release(&view->hdr);
}
r = MSI_DatabaseOpenViewW(package->db, folder_query, &view);
if (r == ERROR_SUCCESS)
msiobj_release(&view->hdr);
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
{
MSIRECORD *uirow;
LPWSTR uipath, p;
LPWSTR dir, uipath, p;
if ( file->state == msifs_installed )
ERR("removing installed file %s\n", debugstr_w(file->TargetPath));
@ -655,8 +661,17 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package )
continue;
TRACE("removing %s\n", debugstr_w(file->File) );
if ( !DeleteFileW( file->TargetPath ) )
TRACE("failed to delete %s\n", debugstr_w(file->TargetPath));
if (!DeleteFileW( file->TargetPath ))
{
WARN("failed to delete %s\n", debugstr_w(file->TargetPath));
}
/* FIXME: check persistence for each directory */
else if (r && (dir = strdupW( file->TargetPath )))
{
if ((p = strrchrW( dir, '\\' ))) *p = 0;
RemoveDirectoryW( dir );
msi_free( dir );
}
file->state = msifs_missing;
/* the UI chunk */

View File

@ -5139,11 +5139,8 @@ static void test_publish(void)
/* no UnpublishFeatures */
r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File deleted\n");
todo_wine
{
ok(!pf_exists("msitest"), "File deleted\n");
}
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
ok(!pf_exists("msitest"), "Directory not deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@ -5218,7 +5215,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(pf_exists("msitest\\maximus"), "File deleted\n");
ok(pf_exists("msitest"), "File deleted\n");
todo_wine ok(pf_exists("msitest"), "Directory deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
@ -5322,10 +5319,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
todo_wine
{
ok(!pf_exists("msitest"), "File not deleted\n");
}
ok(!pf_exists("msitest"), "Directory not deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@ -5400,10 +5394,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
todo_wine
{
ok(!pf_exists("msitest"), "File not deleted\n");
}
ok(!pf_exists("msitest"), "Directory not deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@ -5617,10 +5608,7 @@ static void test_publishsourcelist(void)
r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
todo_wine
{
ok(!pf_exists("msitest"), "File not deleted\n");
}
ok(!pf_exists("msitest"), "Directory not deleted\n");
/* make sure 'Program Files\msitest' is removed */
delete_pfmsitest_files();
@ -6977,10 +6965,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
/* product has been removed */
r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
@ -7005,10 +6990,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
/* product has been removed */
r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
@ -7035,10 +7017,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
@ -7085,10 +7064,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
/* install the product, machine */
r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
@ -7149,10 +7125,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "File not removed\n");
DeleteFileA(msifile);
RegCloseKey(source);
@ -7191,10 +7164,7 @@ static void test_missingcomponent(void)
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
ok(!pf_exists("msitest\\beryllium"), "File installed\n");
todo_wine
{
ok(!delete_pf("msitest", FALSE), "File not removed\n");
}
ok(!delete_pf("msitest", FALSE), "Directory not removed\n");
DeleteFileA(msifile);
DeleteFileA("msitest\\hydrogen");
@ -8268,7 +8238,7 @@ static void test_register_font(void)
r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ret = RegQueryValueExA(key, "msi test font", NULL, NULL, NULL, NULL);
ok(ret == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", ret);
@ -8362,7 +8332,7 @@ static void test_register_typelib(void)
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(!delete_pf("msitest\\typelib.dll", TRUE), "file not removed\n");
todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ok(!delete_pf("msitest", FALSE), "directory not removed\n");
delete_test_files();
}
@ -8425,7 +8395,7 @@ static void test_publish_components(void)
ok(res == ERROR_FILE_NOT_FOUND, "unexpected result %d\n", res);
ok(!delete_pf("msitest\\english.txt", TRUE), "file not removed\n");
todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ok(!delete_pf("msitest", FALSE), "directory not removed\n");
delete_test_files();
}
@ -8529,7 +8499,7 @@ static void test_remove_registry_values(void)
RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine");
ok(!delete_pf("msitest\\registry.txt", TRUE), "file not removed\n");
todo_wine ok(!delete_pf("msitest", FALSE), "directory not removed\n");
ok(!delete_pf("msitest", FALSE), "directory not removed\n");
delete_test_files();
}