Skip to content

Commit

Permalink
fix: binary can not execute
Browse files Browse the repository at this point in the history
  • Loading branch information
bestgopher committed Aug 30, 2024
1 parent bc0c560 commit 1e2ef5b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl WakatimeExtension {
let binary_path = if binary == "wakatime-cli" {
format!("{version_dir}/{target_triple}")
} else {
format!("{version_dir}/{target_triple}/{binary}")
format!("{version_dir}/{binary}")
};

if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
Expand All @@ -85,12 +85,16 @@ impl WakatimeExtension {

for entry in entries {
let entry = entry.map_err(|err| format!("failed to load directory entry {err}"))?;
if entry.file_name().to_str() != Some(&version_dir) {
fs::remove_dir_all(entry.path()).ok();
if let Some(file_name) = entry.file_name().to_str() {
if file_name.starts_with(binary) && file_name != version_dir {
fs::remove_dir_all(entry.path()).ok();
}
}
}
}

zed::make_file_executable(&binary_path)?;

Ok(binary_path)
}

Expand Down Expand Up @@ -145,8 +149,6 @@ impl WakatimeExtension {
let binary_path =
self.download(language_server_id, "wakatime-cli", "wakatime/wakatime-cli")?;

zed::make_file_executable(&binary_path)?;

self.cached_wakatime_cli_binary_path = Some(binary_path.clone());

Ok(binary_path)
Expand Down

0 comments on commit 1e2ef5b

Please sign in to comment.