fixed cuddle image
This commit is contained in:
@@ -9,6 +9,7 @@ use clap::Command;
|
||||
|
||||
use crate::{
|
||||
actions::CuddleAction,
|
||||
config::{CuddleConfig, CuddleFetchPolicy},
|
||||
context::{CuddleContext, CuddleTreeType},
|
||||
model::*,
|
||||
util::git::GitCommit,
|
||||
@@ -23,16 +24,21 @@ pub struct CuddleCli<'a> {
|
||||
context: Arc<Mutex<Vec<CuddleContext>>>,
|
||||
command: Option<Command<'a>>,
|
||||
tmp_dir: Option<PathBuf>,
|
||||
config: CuddleConfig,
|
||||
}
|
||||
|
||||
impl<'a> CuddleCli<'a> {
|
||||
pub fn new(context: Arc<Mutex<Vec<CuddleContext>>>) -> anyhow::Result<CuddleCli<'a>> {
|
||||
pub fn new(
|
||||
context: Arc<Mutex<Vec<CuddleContext>>>,
|
||||
config: CuddleConfig,
|
||||
) -> anyhow::Result<CuddleCli<'a>> {
|
||||
let mut cli = CuddleCli {
|
||||
scripts: vec![],
|
||||
variables: vec![],
|
||||
context: context.clone(),
|
||||
command: None,
|
||||
tmp_dir: None,
|
||||
config,
|
||||
};
|
||||
|
||||
cli = cli
|
||||
@@ -106,8 +112,13 @@ impl<'a> CuddleCli<'a> {
|
||||
.tmp_dir
|
||||
.clone()
|
||||
.ok_or(anyhow::anyhow!("tmp_dir does not exist aborting"))?;
|
||||
if tmp_dir.exists() && tmp_dir.ends_with("tmp") {
|
||||
std::fs::remove_dir_all(tmp_dir.clone())?;
|
||||
match self.config.get_fetch_policy()? {
|
||||
CuddleFetchPolicy::Always => {
|
||||
if tmp_dir.exists() && tmp_dir.ends_with("tmp") {
|
||||
std::fs::remove_dir_all(tmp_dir.clone())?;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
std::fs::create_dir_all(tmp_dir.clone())?;
|
||||
// Handle all templating with variables and such.
|
||||
|
Reference in New Issue
Block a user