diff pkg/imports/sr.go @ 1168:930fdd8b474f

Track successfull imports in a separate table to be able to remove them later.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 14 Nov 2018 12:23:10 +0100
parents 443fc80a315f
children 064d44ccc6f2
line wrap: on
line diff
--- a/pkg/imports/sr.go	Wed Nov 14 12:12:00 2018 +0100
+++ b/pkg/imports/sr.go	Wed Nov 14 12:23:10 2018 +0100
@@ -144,7 +144,12 @@
 `
 )
 
-func (sr SoundingResult) Do(conn *sql.Conn, feedback Feedback) error {
+func (sr SoundingResult) Do(
+	importID int64,
+	ctx context.Context,
+	conn *sql.Conn,
+	feedback Feedback,
+) error {
 
 	z, err := zip.OpenReader(filepath.Join(string(sr), "sr.zip"))
 	if err != nil {
@@ -188,8 +193,6 @@
 		return err
 	}
 
-	ctx := context.Background()
-
 	tx, err := conn.BeginTx(ctx, nil)
 	if err != nil {
 		return err
@@ -261,6 +264,11 @@
 		return err
 	}
 
+	// Store for potential later removal.
+	if err = track(tx, ctx, importID, "waterway.sounding_results", id); err != nil {
+		return err
+	}
+
 	if err = tx.Commit(); err == nil {
 		feedback.Info("Storing sounding result was successful.")
 	}