From bf8cb76096e65c161dd2ec8cb7224b0bc857f680 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Sat, 15 Sep 2018 02:07:16 +0200
Subject: [PATCH] fix race between store import state being updated after
 running channel is closed

---
 importer/job.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/importer/job.go b/importer/job.go
index 1ac6d4c..15ca40f 100644
--- a/importer/job.go
+++ b/importer/job.go
@@ -77,10 +77,10 @@ func (job *Job) run() error {
 		// job.Cancel() only set the state to JobCanceled... so we simulate a canceled context here
 		return context.Canceled
 	}
-	close(job.subC.running)
 	job.StartedAt.set(time.Now())
 	job.im.dbgLog.Printf("running import for %s/%d from: %s", job.Group, job.ID, job.Source.String())
 	job.im.store.UpdateFileImportState(job.Group, job.ID, store.ImportRunning)
+	close(job.subC.running)
 
 	if err := job.initializeSource(); err != nil {
 		job.im.store.UpdateFileImportState(job.Group, job.ID, store.ImportAborted)
-- 
GitLab