proper clean_build of old data at start of new process --- allow to inspect remains of the last process;
--- a/src/Pure/Tools/build_process.scala Mon Mar 06 12:08:33 2023 +0100
+++ b/src/Pure/Tools/build_process.scala Mon Mar 06 15:01:44 2023 +0100
@@ -127,7 +127,10 @@
def prepare_database(): Unit = {
using_option(open_database()) { db =>
- db.transaction { for (table <- Data.all_tables) db.create_table(table) }
+ db.transaction {
+ for (table <- Data.all_tables) db.create_table(table)
+ Data.clean_build(db)
+ }
db.rebuild()
}
}
@@ -302,6 +305,19 @@
stmt.execute()
}
+ def clean_build(db: SQL.Database): Unit = {
+ val old =
+ db.using_statement(
+ Base.table.select(List(Base.build_uuid), sql = SQL.where(Base.end.defined))
+ )(stmt => stmt.execute_query().iterator(_.string(Base.build_uuid)).toList)
+
+ if (old.nonEmpty) {
+ for (table <- List(Base.table, Sessions.table, Progress.table, Workers.table)) {
+ db.using_statement(table.delete(sql = Generic.build_uuid.where_member(old)))(_.execute())
+ }
+ }
+ }
+
/* sessions */