Skip to content

Commit fff2109

Browse files
committed
fix: paths are now just stored as strings (fixes #55)
1 parent 3e40c94 commit fff2109

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/script/sysinfo.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use rhai::{CustomType, TypeBuilder};
2-
use std::path::PathBuf;
32

43
#[derive(Debug, Clone, CustomType)]
54
pub struct SystemInfo {
@@ -24,11 +23,11 @@ pub struct SystemInfo {
2423
#[derive(Debug, Clone, CustomType)]
2524
pub struct SystemInfoPaths {
2625
#[rhai_type(readonly)]
27-
cache_dir: PathBuf,
26+
cache_dir: String,
2827
#[rhai_type(readonly)]
29-
config_dir: PathBuf,
28+
config_dir: String,
3029
#[rhai_type(readonly)]
31-
home_dir: PathBuf,
30+
home_dir: String,
3231
}
3332

3433
impl SystemInfo {
@@ -45,9 +44,15 @@ impl SystemInfo {
4544
desktop_env: whoami::desktop_env().to_string(),
4645
platform: whoami::platform().to_string(),
4746
paths: SystemInfoPaths {
48-
cache_dir: dirs::cache_dir().unwrap_or_else(|| "unknown".into()),
49-
config_dir: dirs::config_dir().unwrap_or_else(|| "unknown".into()),
50-
home_dir: dirs::home_dir().unwrap_or_else(|| "unknown".into()),
47+
cache_dir: dirs::cache_dir()
48+
.map(|x| x.to_string_lossy().to_string())
49+
.unwrap_or_else(|| "unknown".into()),
50+
config_dir: dirs::config_dir()
51+
.map(|x| x.to_string_lossy().to_string())
52+
.unwrap_or_else(|| "unknown".into()),
53+
home_dir: dirs::home_dir()
54+
.map(|x| x.to_string_lossy().to_string())
55+
.unwrap_or_else(|| "unknown".into()),
5156
},
5257
}
5358
}
@@ -57,9 +62,9 @@ impl SystemInfo {
5762
hostname: "canonical-hostname".to_string(),
5863
username: "canonical-username".to_string(),
5964
paths: SystemInfoPaths {
60-
cache_dir: (PathBuf::from("/canonical/cache")),
61-
config_dir: (PathBuf::from("/canonical/config")),
62-
home_dir: (PathBuf::from("/canonical/home")),
65+
cache_dir: "/canonical/cache".to_string(),
66+
config_dir: "/canonical/config".to_string(),
67+
home_dir: "/canonical/home".to_string(),
6368
},
6469
distro: "distro".to_string(),
6570
device_name: "devicename".to_string(),

0 commit comments

Comments
 (0)