msi: Handle errors from IStorage_CreateStream instead of trying to open the stream first in msi_commit_streams.

This commit is contained in:
Hans Leidekker 2015-03-16 10:56:35 +01:00 committed by Alexandre Julliard
parent db3fdbe1e3
commit fa23c7fcb3
2 changed files with 14 additions and 14 deletions

View File

@ -613,16 +613,9 @@ UINT msi_commit_streams( MSIDATABASE *db )
name = msi_string_lookup( db->strings, db->streams[i].str_index, NULL ); name = msi_string_lookup( db->strings, db->streams[i].str_index, NULL );
if (!(encname = encode_streamname( FALSE, name ))) return ERROR_OUTOFMEMORY; if (!(encname = encode_streamname( FALSE, name ))) return ERROR_OUTOFMEMORY;
hr = open_stream( db, encname, &stream ); hr = IStorage_CreateStream( db->storage, encname, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stream );
if (FAILED( hr )) /* new stream */ if (SUCCEEDED( hr ))
{ {
hr = IStorage_CreateStream( db->storage, encname, STGM_WRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &stream );
if (FAILED( hr ))
{
ERR("failed to create stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname );
return ERROR_FUNCTION_FAILED;
}
hr = write_stream( stream, db->streams[i].stream ); hr = write_stream( stream, db->streams[i].stream );
if (FAILED( hr )) if (FAILED( hr ))
{ {
@ -631,12 +624,18 @@ UINT msi_commit_streams( MSIDATABASE *db )
IStream_Release( stream ); IStream_Release( stream );
return ERROR_FUNCTION_FAILED; return ERROR_FUNCTION_FAILED;
} }
hr = IStream_Commit( stream, 0 );
IStream_Release( stream );
if (FAILED( hr ))
{
ERR("failed to commit stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname );
return ERROR_FUNCTION_FAILED;
}
} }
hr = IStream_Commit( stream, 0 ); else if (hr != STG_E_FILEALREADYEXISTS)
IStream_Release( stream );
if (FAILED( hr ))
{ {
WARN("failed to commit stream %s (hr = %08x)\n", debugstr_w(encname), hr); ERR("failed to create stream %s (hr = %08x)\n", debugstr_w(encname), hr);
msi_free( encname ); msi_free( encname );
return ERROR_FUNCTION_FAILED; return ERROR_FUNCTION_FAILED;
} }

View File

@ -3189,7 +3189,8 @@ static void test_try_transform(void)
r = MsiDatabaseApplyTransformA( hdb, mstfile, 0 ); r = MsiDatabaseApplyTransformA( hdb, mstfile, 0 );
ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r ); ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r );
MsiDatabaseCommit( hdb ); r = MsiDatabaseCommit( hdb );
ok( r == ERROR_SUCCESS , "Failed to commit database\n" );
/* check new values */ /* check new values */
hrec = 0; hrec = 0;