summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-12-02 15:53:54 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-06 20:30:32 +0100
commitdaa98bda6543e98e9d1561bdab26cba47c5e8cc5 (patch)
treed7127a1ac0ee919b534c3792e7ad66bfed614631
parent3a35af915583b5e4548ebcce1184231b4a3bfd50 (diff)
reorganize commit process to prepare for adding streams/storages
-rw-r--r--libmsi/msipriv.h4
-rw-r--r--libmsi/msiquery.c48
-rw-r--r--libmsi/storages.c5
-rw-r--r--libmsi/streams.c5
-rw-r--r--libmsi/table.c20
5 files changed, 57 insertions, 25 deletions
diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h
index 9ab7854..398fa7d 100644
--- a/libmsi/msipriv.h
+++ b/libmsi/msipriv.h
@@ -293,7 +293,7 @@ extern void msiobj_addref(LibmsiObject *);
extern int msiobj_release(LibmsiObject *);
extern void free_cached_tables( LibmsiDatabase *db );
-extern unsigned _libmsi_database_commit_tables( LibmsiDatabase *db );
+extern unsigned _libmsi_database_commit_tables( LibmsiDatabase *db, unsigned bytes_per_strref );
/* string table functions */
@@ -320,12 +320,14 @@ extern unsigned read_stream_data( IStorage *stg, const WCHAR *stname, bool table
uint8_t **pdata, unsigned *psz );
extern unsigned write_stream_data( IStorage *stg, const WCHAR *stname,
const void *data, unsigned sz, bool bTable );
+extern unsigned _libmsi_database_commit_streams( LibmsiDatabase *db );
/* transform functions */
extern unsigned msi_table_apply_transform( LibmsiDatabase *db, IStorage *stg );
extern unsigned _libmsi_database_apply_transform( LibmsiDatabase *db,
const char *szTransformFile, int iErrorCond );
extern void append_storage_to_db( LibmsiDatabase *db, IStorage *stg );
+extern unsigned _libmsi_database_commit_storages( LibmsiDatabase *db );
/* record internals */
extern void _libmsi_record_destroy( LibmsiObject * );
diff --git a/libmsi/msiquery.c b/libmsi/msiquery.c
index f4016dc..46d10f2 100644
--- a/libmsi/msiquery.c
+++ b/libmsi/msiquery.c
@@ -602,27 +602,61 @@ LibmsiResult libmsi_database_apply_transform( LibmsiDatabase *db,
LibmsiResult libmsi_database_commit( LibmsiDatabase *db )
{
- unsigned r;
+ unsigned r = LIBMSI_RESULT_SUCCESS;
+ unsigned bytes_per_strref;
+ HRESULT hr;
TRACE("%d\n", db);
- msiobj_addref( &db->hdr );
if( !db )
return LIBMSI_RESULT_INVALID_HANDLE;
+ msiobj_addref( &db->hdr );
if (db->mode == LIBMSI_DB_OPEN_READONLY)
+ goto end;
+
+ /* FIXME: lock the database */
+
+ r = msi_save_string_table( db->strings, db->outfile, &bytes_per_strref );
+ if( r != LIBMSI_RESULT_SUCCESS )
{
- msiobj_release( &db->hdr );
- return LIBMSI_RESULT_SUCCESS;
+ WARN("failed to save string table r=%08x\n",r);
+ goto end;
}
- /* FIXME: lock the database */
+ r = _libmsi_database_commit_storages( db );
+ if (r != LIBMSI_RESULT_SUCCESS)
+ {
+ WARN("failed to save storages r=%08x\n",r);
+ goto end;
+ }
- r = _libmsi_database_commit_tables( db );
- if (r != LIBMSI_RESULT_SUCCESS) ERR("Failed to commit tables!\n");
+ r = _libmsi_database_commit_streams( db );
+ if (r != LIBMSI_RESULT_SUCCESS)
+ {
+ WARN("failed to save streams r=%08x\n",r);
+ goto end;
+ }
+
+ r = _libmsi_database_commit_tables( db, bytes_per_strref );
+ if (r != LIBMSI_RESULT_SUCCESS)
+ {
+ WARN("failed to save tables r=%08x\n",r);
+ goto end;
+ }
+
+ db->bytes_per_strref = bytes_per_strref;
/* FIXME: unlock the database */
+ hr = IStorage_Commit( db->outfile, 0 );
+ if (FAILED( hr ))
+ {
+ WARN("failed to commit changes 0x%08x\n", hr);
+ r = LIBMSI_RESULT_FUNCTION_FAILED;
+ }
+
+end:
msiobj_release( &db->hdr );
if (r == LIBMSI_RESULT_SUCCESS)
diff --git a/libmsi/storages.c b/libmsi/storages.c
index 0c4e8e6..8d88a17 100644
--- a/libmsi/storages.c
+++ b/libmsi/storages.c
@@ -409,3 +409,8 @@ unsigned storages_view_create(LibmsiDatabase *db, LibmsiView **view)
return LIBMSI_RESULT_SUCCESS;
}
+
+unsigned _libmsi_database_commit_storages( LibmsiDatabase *db )
+{
+ return LIBMSI_RESULT_SUCCESS;
+}
diff --git a/libmsi/streams.c b/libmsi/streams.c
index 3defa65..aa1a98b 100644
--- a/libmsi/streams.c
+++ b/libmsi/streams.c
@@ -485,3 +485,8 @@ unsigned streams_view_create(LibmsiDatabase *db, LibmsiView **view)
return LIBMSI_RESULT_SUCCESS;
}
+
+unsigned _libmsi_database_commit_streams( LibmsiDatabase *db )
+{
+ return LIBMSI_RESULT_SUCCESS;
+}
diff --git a/libmsi/table.c b/libmsi/table.c
index 37e5493..39f0f5a 100644
--- a/libmsi/table.c
+++ b/libmsi/table.c
@@ -2061,21 +2061,13 @@ unsigned table_view_create( LibmsiDatabase *db, const WCHAR *name, LibmsiView **
return LIBMSI_RESULT_SUCCESS;
}
-unsigned _libmsi_database_commit_tables( LibmsiDatabase *db )
+unsigned _libmsi_database_commit_tables( LibmsiDatabase *db, unsigned bytes_per_strref )
{
- unsigned r, bytes_per_strref;
- HRESULT hr;
- LibmsiTable *table = NULL;
+ unsigned r = LIBMSI_RESULT_SUCCESS;
+ LibmsiTable *table;
TRACE("%p\n",db);
- r = msi_save_string_table( db->strings, db->outfile, &bytes_per_strref );
- if( r != LIBMSI_RESULT_SUCCESS )
- {
- WARN("failed to save string table r=%08x\n",r);
- return r;
- }
-
LIST_FOR_EACH_ENTRY( table, &db->tables, LibmsiTable, entry )
{
r = save_table( db, table, bytes_per_strref );
@@ -2087,12 +2079,6 @@ unsigned _libmsi_database_commit_tables( LibmsiDatabase *db )
}
}
- hr = IStorage_Commit( db->outfile, 0 );
- if (FAILED( hr ))
- {
- WARN("failed to commit changes 0x%08x\n", hr);
- r = LIBMSI_RESULT_FUNCTION_FAILED;
- }
return r;
}