diff options
author | Roman Melnikov | 2023-04-19 17:46:43 +0800 |
---|---|---|
committer | Roman Melnikov | 2023-04-20 15:13:13 +0800 |
commit | 784e9ee24d977c99dcb5ba5aef81dae48cb899fb (patch) | |
tree | 141acdf6bd62aae808f4c9542819ebc211f09ac2 /src/lib.rs | |
parent | 8c9ea9605eed20528bf60fae35a2b613b901fd77 (diff) |
[Chore] Handle 'temp_path' as an actual 'Path' instead of 'String'
Problem: 'temp_path' and 'lock_path' are handled as 'String'.
This can be a problem when the 'temp_path' directory is a symlink
on the target system, e.g. this is the case with the default
'/tmp' and macOS, where this directory is actually a symlink to '/private/tmp'.
Solution: Handle 'temp_path' and 'lock_path' as actual Paths.
Also, canonicalize 'temp_path' to avoid canary file path mismatches when checking
filesystem events.
As a side effect, also update the 'notify' dependency to the latest stable version.
Diffstat (limited to '')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -12,10 +12,12 @@ use thiserror::Error; use flexi_logger::*; -pub fn make_lock_path(temp_path: &str, closure: &str) -> String { +use std::path::{Path, PathBuf}; + +pub fn make_lock_path(temp_path: &Path, closure: &str) -> PathBuf { let lock_hash = &closure["/nix/store/".len()..closure.find('-').unwrap_or_else(|| closure.len())]; - format!("{}/deploy-rs-canary-{}", temp_path, lock_hash) + temp_path.join(format!("deploy-rs-canary-{}", lock_hash)) } const fn make_emoji(level: log::Level) -> &'static str { @@ -159,7 +161,7 @@ pub struct CmdOverrides { pub auto_rollback: Option<bool>, pub hostname: Option<String>, pub magic_rollback: Option<bool>, - pub temp_path: Option<String>, + pub temp_path: Option<PathBuf>, pub confirm_timeout: Option<u16>, pub sudo: Option<String>, pub dry_activate: bool, |