]> git.phdru.name Git - xsetbg.git/commitdiff
Feat(mv): Begin/commit transaction
authorOleg Broytman <phd@phdru.name>
Wed, 20 Aug 2025 18:06:00 +0000 (21:06 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 20 Aug 2025 18:06:00 +0000 (21:06 +0300)
Abort in case of an error.

mv.py

diff --git a/mv.py b/mv.py
index d727f2859c60a9052bca25f8a3215a8bf29d9c81..9adf21f305a4ceca4433564b79d87538715a43a7 100755 (executable)
--- a/mv.py
+++ b/mv.py
@@ -8,6 +8,8 @@ This file is a part of XSetBg.
 import os
 import sys
 
+from sqlobject.sqlbuilder import LIKE
+
 from xsetbg_db import xsetbg_db
 
 if not xsetbg_db:
@@ -34,10 +36,16 @@ if os.path.exists(to_filename):
 from_filename = os.path.abspath(from_filename)
 to_filename = os.path.abspath(to_filename)
 
+connection = xsetbg_db._connection
+txn = connection.transaction()
+xsetbg_db._connection = txn
+
 rows = list(xsetbg_db.selectBy(full_name=from_filename))
 if not rows:
     sys.exit("No rows by filename %s" % from_filename)
 
 row = rows[0]
 row.full_name = to_filename
+
 os.rename(from_filename, to_filename)
+txn.commit()