fmt: applied formatting
This commit is contained in:
@@ -278,7 +278,7 @@ impl AppConfig {
|
|||||||
if path.exists() {
|
if path.exists() {
|
||||||
return path.clone();
|
return path.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(translated) = paths::translate_sandboxed_home_path(path)
|
if let Some(translated) = paths::translate_sandboxed_home_path(path)
|
||||||
&& translated.exists()
|
&& translated.exists()
|
||||||
{
|
{
|
||||||
@@ -287,10 +287,10 @@ impl AppConfig {
|
|||||||
path.display(),
|
path.display(),
|
||||||
translated.display()
|
translated.display()
|
||||||
);
|
);
|
||||||
|
|
||||||
return translated;
|
return translated;
|
||||||
}
|
}
|
||||||
|
|
||||||
gman::config::Config::local_provider_password_file()
|
gman::config::Config::local_provider_password_file()
|
||||||
}
|
}
|
||||||
None => gman::config::Config::local_provider_password_file(),
|
None => gman::config::Config::local_provider_password_file(),
|
||||||
|
|||||||
+7
-11
@@ -51,7 +51,7 @@ pub fn translate_sandboxed_home_path(path: &Path) -> Option<PathBuf> {
|
|||||||
if let Some(translated) = translate_unix_home_style(s, "/home/") {
|
if let Some(translated) = translate_unix_home_style(s, "/home/") {
|
||||||
return Some(translated);
|
return Some(translated);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(translated) = translate_unix_home_style(s, "/Users/") {
|
if let Some(translated) = translate_unix_home_style(s, "/Users/") {
|
||||||
return Some(translated);
|
return Some(translated);
|
||||||
}
|
}
|
||||||
@@ -65,11 +65,11 @@ fn translate_unix_home_style(s: &str, prefix: &str) -> Option<PathBuf> {
|
|||||||
Some((u, t)) => (u, t),
|
Some((u, t)) => (u, t),
|
||||||
None => (rest, ""),
|
None => (rest, ""),
|
||||||
};
|
};
|
||||||
|
|
||||||
if user.is_empty() || user == "agent" {
|
if user.is_empty() || user == "agent" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(if tail.is_empty() {
|
Some(if tail.is_empty() {
|
||||||
PathBuf::from("/home/agent")
|
PathBuf::from("/home/agent")
|
||||||
} else {
|
} else {
|
||||||
@@ -79,25 +79,21 @@ fn translate_unix_home_style(s: &str, prefix: &str) -> Option<PathBuf> {
|
|||||||
|
|
||||||
fn translate_windows_users_path(s: &str) -> Option<PathBuf> {
|
fn translate_windows_users_path(s: &str) -> Option<PathBuf> {
|
||||||
let bytes = s.as_bytes();
|
let bytes = s.as_bytes();
|
||||||
if bytes.len() < 4
|
if bytes.len() < 4 || !bytes[0].is_ascii_alphabetic() || bytes[1] != b':' || bytes[2] != b'\\' {
|
||||||
|| !bytes[0].is_ascii_alphabetic()
|
|
||||||
|| bytes[1] != b':'
|
|
||||||
|| bytes[2] != b'\\'
|
|
||||||
{
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let after_drive = &s[3..];
|
let after_drive = &s[3..];
|
||||||
let rest = after_drive.strip_prefix("Users\\")?;
|
let rest = after_drive.strip_prefix("Users\\")?;
|
||||||
let (user, tail) = match rest.split_once('\\') {
|
let (user, tail) = match rest.split_once('\\') {
|
||||||
Some((u, t)) => (u, t.replace('\\', "/")),
|
Some((u, t)) => (u, t.replace('\\', "/")),
|
||||||
None => (rest, String::new()),
|
None => (rest, String::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if user.is_empty() || user == "agent" {
|
if user.is_empty() || user == "agent" {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(if tail.is_empty() {
|
Some(if tail.is_empty() {
|
||||||
PathBuf::from("/home/agent")
|
PathBuf::from("/home/agent")
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user