Save deferred import data as a single transaction.

Each of the save_* operations starts a transaction
(which is automatically commited if all goes well).

The main reason for this is to ensure that by the
time raw_lines and final_lines events fire, the
corresponding entries in raw_shots and final_shots
have already been populated.
This commit is contained in:
D. Berge
2020-10-02 19:31:14 +02:00
parent de2deedfd2
commit c013073104

View File

@@ -207,6 +207,8 @@ class Datastore:
"""
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(path, cursor)
count=0
for line in lines:
@@ -271,6 +273,8 @@ class Datastore:
"""
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(filepath, cursor)
incr = records[0]["point_number"] <= records[-1]["point_number"]
@@ -337,6 +341,8 @@ class Datastore:
"""
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(filepath, cursor)
#print(records[0])
#print(records[-1])
@@ -380,6 +386,8 @@ class Datastore:
def save_raw_p111 (self, records, fileinfo, filepath, epsg = 0, filedata = None, ntbp = False):
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(filepath, cursor)
incr = p111.point_number(records[0]) <= p111.point_number(records[-1])
@@ -424,6 +432,8 @@ class Datastore:
def save_final_p111 (self, records, fileinfo, filepath, epsg = 0, filedata = None):
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(filepath, cursor)
qry = """
@@ -464,6 +474,8 @@ class Datastore:
def save_raw_smsrc (self, records, fileinfo, filepath, filedata = None):
with self.conn.cursor() as cursor:
cursor.execute("BEGIN;")
hash = self.add_file(filepath, cursor)
# Start by deleting any online data we may have for this sequence