forked from Mirrors/wine-wine
msi: Delete databases we create but never commit.
parent
1c60e3bfc5
commit
74a6a1e71b
|
@ -64,6 +64,11 @@ static VOID MSI_CloseDatabase( MSIOBJECTHDR *arg )
|
||||||
r = IStorage_Release( db->storage );
|
r = IStorage_Release( db->storage );
|
||||||
if( r )
|
if( r )
|
||||||
ERR("database reference count was not zero (%ld)\n", r);
|
ERR("database reference count was not zero (%ld)\n", r);
|
||||||
|
if (db->deletefile)
|
||||||
|
{
|
||||||
|
DeleteFileW( db->deletefile );
|
||||||
|
msi_free( db->deletefile );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
||||||
|
@ -74,6 +79,7 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
||||||
UINT ret = ERROR_FUNCTION_FAILED;
|
UINT ret = ERROR_FUNCTION_FAILED;
|
||||||
LPCWSTR szMode;
|
LPCWSTR szMode;
|
||||||
STATSTG stat;
|
STATSTG stat;
|
||||||
|
BOOL created = FALSE;
|
||||||
|
|
||||||
TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
|
TRACE("%s %s\n",debugstr_w(szDBPath),debugstr_w(szPersist) );
|
||||||
|
|
||||||
|
@ -83,12 +89,15 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
||||||
szMode = szPersist;
|
szMode = szPersist;
|
||||||
if( HIWORD( szPersist ) )
|
if( HIWORD( szPersist ) )
|
||||||
{
|
{
|
||||||
/* UINT len = lstrlenW( szPerist ) + 1; */
|
if (!CopyFileW( szDBPath, szPersist, FALSE ))
|
||||||
FIXME("don't support persist files yet\b");
|
return ERROR_OPEN_FAILED;
|
||||||
return ERROR_INVALID_PARAMETER;
|
|
||||||
/* szMode = msi_alloc( len * sizeof (DWORD) ); */
|
szDBPath = szPersist;
|
||||||
|
szPersist = MSIDBOPEN_TRANSACT;
|
||||||
|
created = TRUE;
|
||||||
}
|
}
|
||||||
else if( szPersist == MSIDBOPEN_READONLY )
|
|
||||||
|
if( szPersist == MSIDBOPEN_READONLY )
|
||||||
{
|
{
|
||||||
r = StgOpenStorage( szDBPath, NULL,
|
r = StgOpenStorage( szDBPath, NULL,
|
||||||
STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
|
STGM_DIRECT|STGM_READ|STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
|
||||||
|
@ -104,6 +113,7 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
||||||
IStorage_SetClass( stg, &CLSID_MsiDatabase );
|
IStorage_SetClass( stg, &CLSID_MsiDatabase );
|
||||||
r = init_string_table( stg );
|
r = init_string_table( stg );
|
||||||
}
|
}
|
||||||
|
created = TRUE;
|
||||||
}
|
}
|
||||||
else if( szPersist == MSIDBOPEN_TRANSACT )
|
else if( szPersist == MSIDBOPEN_TRANSACT )
|
||||||
{
|
{
|
||||||
|
@ -157,6 +167,10 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
|
||||||
|
|
||||||
db->storage = stg;
|
db->storage = stg;
|
||||||
db->mode = szMode;
|
db->mode = szMode;
|
||||||
|
if (created)
|
||||||
|
db->deletefile = strdupW( szDBPath );
|
||||||
|
else
|
||||||
|
db->deletefile = NULL;
|
||||||
list_init( &db->tables );
|
list_init( &db->tables );
|
||||||
list_init( &db->transforms );
|
list_init( &db->transforms );
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ typedef struct tagMSIDATABASE
|
||||||
MSIOBJECTHDR hdr;
|
MSIOBJECTHDR hdr;
|
||||||
IStorage *storage;
|
IStorage *storage;
|
||||||
string_table *strings;
|
string_table *strings;
|
||||||
|
LPWSTR deletefile;
|
||||||
LPCWSTR mode;
|
LPCWSTR mode;
|
||||||
struct list tables;
|
struct list tables;
|
||||||
struct list transforms;
|
struct list transforms;
|
||||||
|
|
|
@ -753,6 +753,12 @@ UINT WINAPI MsiDatabaseCommit( MSIHANDLE hdb )
|
||||||
|
|
||||||
msiobj_release( &db->hdr );
|
msiobj_release( &db->hdr );
|
||||||
|
|
||||||
|
if (r == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
msi_free( db->deletefile );
|
||||||
|
db->deletefile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,15 @@ static void test_msidatabase(void)
|
||||||
|
|
||||||
DeleteFile(msifile);
|
DeleteFile(msifile);
|
||||||
|
|
||||||
|
res = MsiOpenDatabase( msifile, msifile2, &hdb );
|
||||||
|
ok( res == ERROR_OPEN_FAILED, "expected failure\n");
|
||||||
|
|
||||||
|
res = MsiOpenDatabase( msifile, (LPSTR) 0xff, &hdb );
|
||||||
|
ok( res == ERROR_INVALID_PARAMETER, "expected failure\n");
|
||||||
|
|
||||||
|
res = MsiCloseHandle( hdb );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
|
||||||
/* create an empty database */
|
/* create an empty database */
|
||||||
res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
|
res = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to create database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to create database\n" );
|
||||||
|
@ -51,18 +60,36 @@ static void test_msidatabase(void)
|
||||||
|
|
||||||
res = MsiCloseHandle( hdb );
|
res = MsiCloseHandle( hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
todo_wine {
|
|
||||||
res = MsiOpenDatabase( msifile, msifile2, &hdb2 );
|
res = MsiOpenDatabase( msifile, msifile2, &hdb2 );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
||||||
|
|
||||||
ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes( msifile2 ), "database should exist\n");
|
ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes( msifile2 ), "database should exist\n");
|
||||||
|
|
||||||
res = MsiDatabaseCommit( hdb2 );
|
res = MsiDatabaseCommit( hdb2 );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
|
||||||
}
|
|
||||||
res = MsiCloseHandle( hdb2 );
|
res = MsiCloseHandle( hdb2 );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
|
||||||
|
res = MsiOpenDatabase( msifile, msifile2, &hdb2 );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
||||||
|
|
||||||
|
res = MsiCloseHandle( hdb2 );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
|
||||||
|
ok( INVALID_FILE_ATTRIBUTES == GetFileAttributes( msifile2 ), "uncommitted database should not exist\n");
|
||||||
|
|
||||||
|
res = MsiOpenDatabase( msifile, msifile2, &hdb2 );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
|
||||||
|
res = MsiDatabaseCommit( hdb2 );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
|
||||||
|
|
||||||
|
res = MsiCloseHandle( hdb2 );
|
||||||
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
|
||||||
|
ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes( msifile2 ), "committed database should exist\n");
|
||||||
|
|
||||||
res = MsiOpenDatabase( msifile, MSIDBOPEN_READONLY, &hdb );
|
res = MsiOpenDatabase( msifile, MSIDBOPEN_READONLY, &hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
||||||
|
|
||||||
|
@ -80,9 +107,9 @@ static void test_msidatabase(void)
|
||||||
|
|
||||||
res = MsiCloseHandle( hdb );
|
res = MsiCloseHandle( hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
todo_wine {
|
ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes( msifile ), "database should exist\n");
|
||||||
ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes( msifile2 ), "database should exist\n");
|
|
||||||
|
|
||||||
|
todo_wine {
|
||||||
/* MSIDBOPEN_CREATE deletes the database if MsiCommitDatabase isn't called */
|
/* MSIDBOPEN_CREATE deletes the database if MsiCommitDatabase isn't called */
|
||||||
res = MsiOpenDatabase( msifile, MSIDBOPEN_CREATE, &hdb );
|
res = MsiOpenDatabase( msifile, MSIDBOPEN_CREATE, &hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to open database\n" );
|
||||||
|
@ -98,10 +125,10 @@ static void test_msidatabase(void)
|
||||||
|
|
||||||
res = MsiCloseHandle( hdb );
|
res = MsiCloseHandle( hdb );
|
||||||
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
|
||||||
|
}
|
||||||
res = DeleteFile( msifile2 );
|
res = DeleteFile( msifile2 );
|
||||||
ok( res == TRUE, "Failed to delete database\n" );
|
ok( res == TRUE, "Failed to delete database\n" );
|
||||||
}
|
|
||||||
res = DeleteFile( msifile );
|
res = DeleteFile( msifile );
|
||||||
ok( res == TRUE, "Failed to delete database\n" );
|
ok( res == TRUE, "Failed to delete database\n" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue