more robust update of generated directory;
authorwenzelm
Tue May 09 21:06:11 2017 +0200 (2017-05-09)
changeset 6579396b4799a2e04
parent 65792 c58752102b34
child 65794 a880f41a8d0f
more robust update of generated directory;
tuned;
src/Pure/Admin/isabelle_cronjob.scala
src/Pure/Admin/isabelle_devel.scala
src/Pure/System/isabelle_system.scala
     1.1 --- a/src/Pure/Admin/isabelle_cronjob.scala	Tue May 09 20:36:34 2017 +0200
     1.2 +++ b/src/Pure/Admin/isabelle_cronjob.scala	Tue May 09 21:06:11 2017 +0200
     1.3 @@ -360,9 +360,7 @@
     1.4              Logger_Task("build_log_database",
     1.5                logger => Isabelle_Devel.build_log_database(logger.options)),
     1.6              Logger_Task("build_status",
     1.7 -              logger =>
     1.8 -                Build_Status.build_status(logger.options,
     1.9 -                  target_dir = Isabelle_Devel.build_status_dir)))))))
    1.10 +              logger => Isabelle_Devel.build_status(logger.options)))))))
    1.11  
    1.12      log_service.shutdown()
    1.13  
     2.1 --- a/src/Pure/Admin/isabelle_devel.scala	Tue May 09 20:36:34 2017 +0200
     2.2 +++ b/src/Pure/Admin/isabelle_devel.scala	Tue May 09 21:06:11 2017 +0200
     2.3 @@ -18,8 +18,6 @@
     2.4    val standard_log_dirs =
     2.5      List(Path.explode("~/log"), Path.explode("~/afp/log"), Path.explode("~/cronjob/log"))
     2.6  
     2.7 -  val build_status_dir = root + Path.explode(BUILD_STATUS)
     2.8 -
     2.9  
    2.10    /* index */
    2.11  
    2.12 @@ -60,20 +58,10 @@
    2.13    {
    2.14      Isabelle_System.with_tmp_dir("isadist")(base_dir =>
    2.15        {
    2.16 -        val release_snapshot_dir = root + Path.explode(RELEASE_SNAPSHOT)
    2.17 -
    2.18 -        val new_snapshot = release_snapshot_dir.ext("new")
    2.19 -        val old_snapshot = release_snapshot_dir.ext("old")
    2.20 -
    2.21 -        Isabelle_System.rm_tree(new_snapshot)
    2.22 -        Isabelle_System.rm_tree(old_snapshot)
    2.23 -
    2.24 -        Build_Release.build_release(base_dir, rev = rev, afp_rev = afp_rev,
    2.25 -          parallel_jobs = parallel_jobs, remote_mac = remote_mac, website = Some(new_snapshot))
    2.26 -
    2.27 -        if (release_snapshot_dir.is_dir) File.move(release_snapshot_dir, old_snapshot)
    2.28 -        File.move(new_snapshot, release_snapshot_dir)
    2.29 -        Isabelle_System.rm_tree(old_snapshot)
    2.30 +        Isabelle_System.update_directory(root + Path.explode(RELEASE_SNAPSHOT),
    2.31 +          website_dir =>
    2.32 +            Build_Release.build_release(base_dir, rev = rev, afp_rev = afp_rev,
    2.33 +              parallel_jobs = parallel_jobs, remote_mac = remote_mac, website = Some(website_dir)))
    2.34        })
    2.35    }
    2.36  
    2.37 @@ -89,4 +77,13 @@
    2.38        store.snapshot_database(db, root + Path.explode(BUILD_LOG_DB))
    2.39      })
    2.40    }
    2.41 +
    2.42 +
    2.43 +  /* present build status */
    2.44 +
    2.45 +  def build_status(options: Options)
    2.46 +  {
    2.47 +    Isabelle_System.update_directory(root + Path.explode(BUILD_STATUS),
    2.48 +      dir => Build_Status.build_status(options, target_dir = dir))
    2.49 +  }
    2.50  }
     3.1 --- a/src/Pure/System/isabelle_system.scala	Tue May 09 20:36:34 2017 +0200
     3.2 +++ b/src/Pure/System/isabelle_system.scala	Tue May 09 21:06:11 2017 +0200
     3.3 @@ -237,6 +237,24 @@
     3.4    }
     3.5  
     3.6  
     3.7 +  /* quasi-atomic update of directory */
     3.8 +
     3.9 +  def update_directory(dir: Path, f: Path => Unit)
    3.10 +  {
    3.11 +    val new_dir = dir.ext("new")
    3.12 +    val old_dir = dir.ext("old")
    3.13 +
    3.14 +    rm_tree(new_dir)
    3.15 +    rm_tree(old_dir)
    3.16 +
    3.17 +    f(new_dir)
    3.18 +
    3.19 +    if (dir.is_dir) File.move(dir, old_dir)
    3.20 +    File.move(new_dir, dir)
    3.21 +    rm_tree(old_dir)
    3.22 +  }
    3.23 +
    3.24 +
    3.25  
    3.26    /** external processes **/
    3.27