mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 13:07:08 +00:00
Do not import gun data if sequence has no shots.
Doing otherwise will result in the gun data file appearing has having been read, but no data will have been saved as there was nowhere to save to. Fixes #29.
This commit is contained in:
@@ -483,6 +483,21 @@ class Datastore:
|
||||
#self.del_hash("*online*", cursor)
|
||||
|
||||
# The shots should already exist, e.g., from a P1 import
|
||||
# …but what about if the SMSRC file gets read *before* the P1?
|
||||
# We need to check
|
||||
qry = "SELECT count(*) FROM raw_shots WHERE sequence = %s;"
|
||||
values = (fileinfo["sequence"],)
|
||||
cursor.execute(qry, values)
|
||||
shotcount = cursor.fetchone()[0]
|
||||
if shotcount == 0:
|
||||
# No shots yet or not all imported, so we do *not*
|
||||
# save the gun data. It will eventually get picked
|
||||
# up in the next run.
|
||||
# Let's remove the file from the file list and bail
|
||||
# out.
|
||||
print("No raw shots for sequence", fileinfo["sequence"])
|
||||
self.conn.rollback()
|
||||
return
|
||||
|
||||
values = [ (json.dumps(record), fileinfo["sequence"], record["shot"]) for record in records ]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user