From 6eb496cf45a193d0945a3b6a84af693c6f44d7b7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 Aug 2011 20:04:02 +0200 Subject: dbcheck: Cancel transaction if operation fails. Autobuild-User: Jelmer Vernooij Autobuild-Date: Tue Aug 2 01:41:07 CEST 2011 on sn-devel-104 --- source4/scripting/python/samba/netcmd/dbcheck.py | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source4/scripting') diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py index 3f379c0cd4..2a175f3525 100644 --- a/source4/scripting/python/samba/netcmd/dbcheck.py +++ b/source4/scripting/python/samba/netcmd/dbcheck.py @@ -96,16 +96,21 @@ class cmd_dbcheck(Command): if yes and fix: samdb.transaction_start() - - chk = dbcheck(samdb, samdb_schema=samdb_schema, verbose=verbose, fix=fix, yes=yes, quiet=quiet) - - if reindex: - print("Re-indexing...") - error_count = 0 - if chk.reindex_database(): - print("completed re-index OK") - else: - error_count = chk.check_database(DN=DN, scope=search_scope, controls=controls, attrs=attrs) + try: + chk = dbcheck(samdb, samdb_schema=samdb_schema, verbose=verbose, + fix=fix, yes=yes, quiet=quiet) + + if reindex: + print("Re-indexing...") + error_count = 0 + if chk.reindex_database(): + print("completed re-index OK") + else: + error_count = chk.check_database(DN=DN, scope=search_scope, + controls=controls, attrs=attrs) + except: + samdb.transaction_cancel() + raise if yes and fix: samdb.transaction_commit() -- cgit