msi: Fix handling of components without a key path in MsiEnumComponentCostsW.

This commit is contained in:
Hans Leidekker 2011-05-02 16:02:25 +02:00 committed by Alexandre Julliard
parent ee683f7162
commit b4a7a30b18
2 changed files with 23 additions and 7 deletions

View File

@ -1864,12 +1864,22 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
drive[0] = 0;
*cost = *temp = 0;
GetWindowsDirectoryW( path, MAX_PATH );
if (component && component[0])
{
*cost = max( 8, comp->Cost / 512 );
if (comp->assembly && !comp->assembly->application) *temp = comp->Cost;
if ((file = get_loaded_file( package, comp->KeyPath )))
if (!comp->Enabled || !comp->KeyPath)
{
*cost = 0;
drive[0] = path[0];
drive[1] = ':';
drive[2] = 0;
*buflen = 2;
r = ERROR_SUCCESS;
}
else if ((file = get_loaded_file( package, comp->KeyPath )))
{
*cost = max( 8, comp->Cost / 512 );
drive[0] = file->TargetPath[0];
drive[1] = ':';
drive[2] = 0;
@ -1880,7 +1890,6 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
else if (IStorage_Stat( package->db->storage, &stat, STATFLAG_NONAME ) == S_OK)
{
*temp = max( 8, stat.cbSize.QuadPart / 512 );
GetWindowsDirectoryW( path, MAX_PATH );
drive[0] = path[0];
drive[1] = ':';
drive[2] = 0;

View File

@ -12942,16 +12942,13 @@ static void test_MsiEnumComponentCosts(void)
r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
r = add_file_entry( hdb, "'two.txt', 'two', 'two.txt', 8192, '', '', 8192, 2" );
ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
r = create_component_table( hdb );
ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', 'two.txt'" );
r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
r = create_feature_table( hdb );
@ -13100,6 +13097,16 @@ static void test_MsiEnumComponentCosts(void)
ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
ok( !temp, "expected temp == 0, got %d\n", temp );
len = sizeof(drive);
drive[0] = 0;
cost = temp = 0xdead;
r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
ok( len == 2, "expected len == 2, got %u\n", len );
ok( drive[0], "expected a drive\n" );
ok( !cost, "expected cost == 0, got %d\n", cost );
ok( !temp, "expected temp == 0, got %d\n", temp );
len = sizeof(drive);
drive[0] = 0;
cost = temp = 0xdead;