src/Pure/Build/build_manager.scala
changeset 80780 d6417e967a7c
parent 80779 a1b3abc629af
child 80781 11e33f3d5ef1
--- a/src/Pure/Build/build_manager.scala	Tue Aug 27 12:57:49 2024 +0200
+++ b/src/Pure/Build/build_manager.scala	Tue Aug 27 13:12:10 2024 +0200
@@ -1019,7 +1019,20 @@
 
     override def stopped(state: Runner.State): Boolean = progress.stopped && state.is_empty
 
-    def init: Runner.State = Runner.State.init(store.options)
+    def init: Runner.State = synchronized_database("init") {
+      for ((name, job) <- _state.running) {
+        echo("Cleaned up job " + job.uuid)
+
+        val report = store.report(job.kind, job.id)
+
+        _state = _state
+          .remove_running(job.name)
+          .add_finished(report.result(Some(job.uuid), job.user))
+      }
+
+      Runner.State.init(store.options)
+    }
+
     def loop_body(state: Runner.State): Runner.State = {
       val state1 =
         if (progress.stopped) state