From 748d06a3b515e92b36d614eaa15c6ba5296cae9c Mon Sep 17 00:00:00 2001 From: Alexandr Sorokin Date: Tue, 11 Jun 2024 17:30:41 +0300 Subject: [PATCH] Add symlink on latest state --- src/task/cluster.rs | 2 +- src/task/state.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/task/cluster.rs b/src/task/cluster.rs index 1cd7403..db55eba 100644 --- a/src/task/cluster.rs +++ b/src/task/cluster.rs @@ -801,7 +801,7 @@ impl Cluster { .build()?; state.dump_by_uid(&state_dir)?; - state.dump_by_path(latest_path)?; + state.symlink_latest(latest_path)?; Ok(self) } diff --git a/src/task/state.rs b/src/task/state.rs index 4ca12a1..7e58cf8 100644 --- a/src/task/state.rs +++ b/src/task/state.rs @@ -2,6 +2,7 @@ use std::{ fmt::Display, fs::{create_dir_all, remove_dir_all, File}, io::{self, Read, Write}, + os::unix::fs, path::PathBuf, }; @@ -112,6 +113,10 @@ impl State { self.dump_by_path(&format!("{state_dir}/{}.gz", &self.uid)) } + pub fn symlink_latest(&mut self, latest: &str) -> Result<(), io::Error> { + fs::symlink(&format!("{}.gz", &self.uid), latest) + } + pub fn from_latest(args: &ArgMatches) -> Result { let path = format!( "{}/latest.gz",