Commit b4a7a30b authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

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

parent ee683f71
......@@ -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;
......
......@@ -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 );
......@@ -13103,6 +13100,16 @@ static void test_MsiEnumComponentCosts(void)
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;
r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, 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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment