Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symlink for latest state #164

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ pub fn run_v2() -> Result<(), Box<dyn Error>> {
Ok(())
}

#[allow(dead_code)]
pub trait Validate {
type Type: fmt::Debug + Default + 'static;
type Error: fmt::Debug + ToString;
Expand Down
2 changes: 1 addition & 1 deletion src/task/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions src/task/cluster/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ impl FsInteraction {
}
}

#[allow(dead_code)]

pub trait TryIntoFile {
type Error;

Expand Down Expand Up @@ -126,6 +128,7 @@ impl<'a> From<&'a ArgMatches> for IO<PathBuf, PathBuf> {
}
}

#[allow(dead_code)]
pub trait TryMap<A, B> {
type Error;
type Output;
Expand Down
5 changes: 5 additions & 0 deletions src/task/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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<Self, StateError> {
let path = format!(
"{}/latest.gz",
Expand Down
Loading