r19682 - gnucash/trunk/src/backend/sql - Bug 632166: gnc_backend_sql_sync_all: Commit only if all operations were successful; otherwise roll back.

John Ralls jralls at code.gnucash.org
Tue Oct 19 18:42:43 EDT 2010


Author: jralls
Date: 2010-10-19 18:42:43 -0400 (Tue, 19 Oct 2010)
New Revision: 19682
Trac: http://svn.gnucash.org/trac/changeset/19682

Modified:
   gnucash/trunk/src/backend/sql/gnc-backend-sql.c
Log:
Bug 632166: gnc_backend_sql_sync_all: Commit only if all operations were successful; otherwise roll back. 

Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2010-10-19 21:22:42 UTC (rev 19681)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c	2010-10-19 22:42:43 UTC (rev 19682)
@@ -519,13 +519,18 @@
     {
         qof_object_foreach_backend( GNC_SQL_BACKEND, write_cb, be );
     }
+    if ( is_ok ) 
+    {
+	(void)gnc_sql_connection_commit_transaction( be->conn );
+	be->is_pristine_db = FALSE;
 
-    (void)gnc_sql_connection_commit_transaction( be->conn );
-    be->is_pristine_db = FALSE;
-
-    // Mark the book as clean
-    qof_book_mark_saved( book );
-
+	// Mark the book as clean
+	qof_book_mark_saved( book );
+    }
+    else
+    {
+	gnc_sql_connection_rollback_transaction( be->conn );
+    }
     LEAVE( "book=%p", book );
 }
 



More information about the gnucash-changes mailing list