diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-02 15:53:54 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-06 20:30:32 +0100 |
commit | daa98bda6543e98e9d1561bdab26cba47c5e8cc5 (patch) | |
tree | d7127a1ac0ee919b534c3792e7ad66bfed614631 /libmsi/msiquery.c | |
parent | 3a35af915583b5e4548ebcce1184231b4a3bfd50 (diff) | |
download | msitools-daa98bda6543e98e9d1561bdab26cba47c5e8cc5.tar.gz msitools-daa98bda6543e98e9d1561bdab26cba47c5e8cc5.tar.xz msitools-daa98bda6543e98e9d1561bdab26cba47c5e8cc5.zip |
reorganize commit process to prepare for adding streams/storages
Diffstat (limited to 'libmsi/msiquery.c')
-rw-r--r-- | libmsi/msiquery.c | 48 |
1 files changed, 41 insertions, 7 deletions
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) |