From: Jelmer Vernooij Date: Mon, 1 Aug 2011 18:04:02 +0000 (+0200) Subject: dbcheck: Cancel transaction if operation fails. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=6eb496cf45a193d0945a3b6a84af693c6f44d7b7;p=rusty%2Fsamba.git dbcheck: Cancel transaction if operation fails. Autobuild-User: Jelmer Vernooij Autobuild-Date: Tue Aug 2 01:41:07 CEST 2011 on sn-devel-104 --- diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py index 3f379c0cd4d..2a175f3525e 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()