src/Pure/Tools/build.scala
changeset 68220 8fc4e3d1df86
parent 68219 c0341c0080e2
child 68221 dbef88c2b6c5
--- a/src/Pure/Tools/build.scala	Sat May 19 15:45:45 2018 +0200
+++ b/src/Pure/Tools/build.scala	Sat May 19 16:13:39 2018 +0200
@@ -467,19 +467,13 @@
 
     store.prepare_output_dir()
 
-    // cleanup
-    def cleanup(name: String, echo: Boolean = false)
-    {
-      val files =
-        List(Path.basic(name), store.database(name), store.log(name), store.log_gz(name)).
-          map(store.output_dir + _).filter(_.is_file)
-      if (files.nonEmpty) progress.echo_if(echo, "Cleaning " + name + " ...")
-      val res = files.map(p => p.file.delete)
-      if (!res.forall(ok => ok)) progress.echo_if(echo, name + " FAILED to delete")
-    }
     if (clean_build) {
       for (name <- full_sessions.build_descendants(full_sessions.build_selection(selection1))) {
-        cleanup(name, echo = true)
+        val (relevant, ok) = store.clean_output(name)
+        if (relevant) {
+          if (ok) progress.echo("Cleaned " + name)
+          else progress.echo(name + " FAILED to clean")
+        }
       }
     }
 
@@ -618,7 +612,7 @@
                 else if (ancestor_results.forall(_.ok) && !progress.stopped) {
                   progress.echo((if (do_output) "Building " else "Running ") + name + " ...")
 
-                  cleanup(name)
+                  store.clean_output(name)
                   using(store.open_output_database(name))(store.init_session_info(_, name))
 
                   val numa_node = numa_nodes.next(used_node(_))