Do not use a Transaction to copy SQLite database for tests restoration
Starting a Transaction can only be done on a already setup database as the cache synchronisation may query the `ir_cache` table. Closes #14742 (grafted from 205b618af9b4fa41625b7b7d3d118151fe421eca) --HG-- branch : 7.0
This commit is contained in:
1 parent
f947b1ee92
commit
aae65670be
1 file changed
+6
-2
@@ -165,8 +165,9 @@ def _sqlite_copy(file_, restore=False):
|
||||
finally:
|
||||
database.put_connection(connection, True)
|
||||
|
||||
with Transaction().start(DB_NAME, 0) as transaction:
|
||||
conn1 = transaction.connection
|
||||
database = backend.Database(DB_NAME).connect()
|
||||
conn1 = database.get_connection()
|
||||
try:
|
||||
with sqlite.connect(file_) as conn2:
|
||||
if restore:
|
||||
in_, out = conn2, conn1
|
||||
@@ -181,6 +182,9 @@ def _sqlite_copy(file_, restore=False):
|
||||
return False
|
||||
sqlitebck.copy(in_, out)
|
||||
conn2.close()
|
||||
finally:
|
||||
database.put_connection(conn1)
|
||||
database.close()
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user