diff --git a/src/helpers/src/config.rs b/src/helpers/src/config.rs index 0d23983..782f3a2 100644 --- a/src/helpers/src/config.rs +++ b/src/helpers/src/config.rs @@ -17,6 +17,7 @@ lazy_static! { pub static ref WEBSITE_REPOSITORY: String = env::var("WEBSITE_REPOSITORY") .expect("Environment variable `WEBSITE_REPOSITORY` is required."); pub static ref BASE_DIR: PathBuf = WORK_DIR.join(".orangutan"); + pub static ref TMP_DIR: PathBuf = BASE_DIR.join("tmp"); pub static ref KEYS_DIR: PathBuf = BASE_DIR.join("keys"); pub static ref MODE: Result = env::var("MODE"); pub static ref KEYS_MODE: Result = env::var("KEYS_MODE"); diff --git a/src/helpers/src/generate.rs b/src/helpers/src/generate.rs index c663590..8408b14 100644 --- a/src/helpers/src/generate.rs +++ b/src/helpers/src/generate.rs @@ -21,7 +21,7 @@ static DATA_FILES_GENERATED: AtomicBool = AtomicBool::new(false); lazy_static! { // NOTE: `Arc` prevents race conditions static ref GENERATED_WEBSITES: Arc>> = Arc::new(Mutex::new(HashSet::new())); - static ref TMP_DIR: PathBuf = std::env::temp_dir().join("orangutan-save"); + static ref TRASH_DIR: PathBuf = TMP_DIR.join("trash"); } pub fn generate_default_website() -> Result<(), Error> { @@ -350,7 +350,7 @@ pub fn trash_outdated_websites() -> Result { trace!("Trashing outdated websites…"); // Remove outdated websites - fs::rename(DEST_DIR.as_path(), TMP_DIR.as_path()).map_err(Error::IOError)?; + fs::rename(DEST_DIR.as_path(), TRASH_DIR.as_path()).map_err(Error::IOError)?; // Save caches (in case we need to recover) let state = State { @@ -373,7 +373,7 @@ pub fn recover_trash(state: State) -> Result<(), Error> { trace!("Recovering trash…"); // Reload files - fs::rename(TMP_DIR.as_path(), DEST_DIR.as_path()).map_err(Error::IOError)?; + fs::rename(TRASH_DIR.as_path(), DEST_DIR.as_path()).map_err(Error::IOError)?; // Relaod caches HUGO_CONFIG_GENERATED.store(state.hugo_config_generated, Ordering::Relaxed); @@ -388,7 +388,7 @@ pub fn recover_trash(state: State) -> Result<(), Error> { pub fn empty_trash(_state: State) -> Result<(), Error> { trace!("Emptying trash…"); - fs::remove_dir_all(TMP_DIR.as_path()).map_err(Error::IOError)?; + fs::remove_dir_all(TRASH_DIR.as_path()).map_err(Error::IOError)?; Ok(()) }