Skip to content

Commit 05a1c6f

Browse files
committed
feat:auto download essential modules
1 parent 69bb892 commit 05a1c6f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src-tauri/src/modules_dl.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ async fn download_module(url: &str) -> Result<(), Box<dyn std::error::Error>> {
2323
while let Some(chunk) = response.chunk().await? {
2424
file.write_all(&chunk)?;
2525
}
26-
// TODO: testing check if it matches correctly
2726
let tar_regex = Regex::new(r"(?i)\.tar(?:\.gz)?$").unwrap();
2827
if file_name.ends_with(".zip") {
2928
let output = std::process::Command::new("unzip")
@@ -94,18 +93,10 @@ pub(crate) async fn download_modules() -> Result<(), Box<dyn std::error::Error>>
9493
Ok(())
9594
}
9695

96+
#[cfg(target_os = "linux")]
9797
pub(crate) fn has_essential_modules(modules: Vec<String>) -> bool {
98-
// TODO: confirm that windows and mac the watchers are separate and not in the same module
99-
100-
let essential_modules = if cfg!(target_os = "linux") {
101-
if is_wayland() {
102-
vec!["aw-awatcher".to_string()]
103-
} else {
104-
vec![
105-
"aw-watcher-afk".to_string(),
106-
"aw-watcher-window".to_string(),
107-
]
108-
}
98+
let essential_modules = if is_wayland() {
99+
vec!["aw-awatcher".to_string()]
109100
} else {
110101
vec![
111102
"aw-watcher-afk".to_string(),
@@ -120,3 +111,18 @@ pub(crate) fn has_essential_modules(modules: Vec<String>) -> bool {
120111
}
121112
true
122113
}
114+
115+
#[cfg(not(any(target_os = "linux")))]
116+
pub(crate) fn has_essential_modules(modules: Vec<String>) -> bool {
117+
let essential_modules = vec![
118+
"aw-watcher-afk".to_string(),
119+
"aw-watcher-window".to_string(),
120+
];
121+
122+
for module in essential_modules {
123+
if !modules.iter().any(|m| m == &module) {
124+
return false;
125+
}
126+
}
127+
true
128+
}

0 commit comments

Comments
 (0)