summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-08-01 20:04:02 +0200
committerJelmer Vernooij <jelmer@samba.org>2011-08-02 01:41:07 +0200
commit6eb496cf45a193d0945a3b6a84af693c6f44d7b7 (patch)
tree4f5929ba5e5621e58a1ab4570ed3462a3878cb81 /source4/scripting
parent0c67efdd68b9808542c090b9fd9920e4e37d85d0 (diff)
downloadsamba-6eb496cf45a193d0945a3b6a84af693c6f44d7b7.tar.gz
samba-6eb496cf45a193d0945a3b6a84af693c6f44d7b7.tar.bz2
samba-6eb496cf45a193d0945a3b6a84af693c6f44d7b7.zip
dbcheck: Cancel transaction if operation fails.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Tue Aug 2 01:41:07 CEST 2011 on sn-devel-104
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/dbcheck.py25
1 files changed, 15 insertions, 10 deletions
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()