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 e0f257b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wakatime-zed"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id = "wakatime"
name = "wakatime"
description = "Wakatime support."
version = "0.0.1"
version = "0.1.1"
schema_version = 1
authors = ["bestgopher <84328409@qq.com>"]
repository = "https://github.com/bestgopher/wakatime-zed"
Expand Down
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
2 changes: 1 addition & 1 deletion wakatime-ls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wakatime-ls"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
repository = "https://github.com/bestgopher/wakatime-zed"

Expand Down

0 comments on commit e0f257b

Please sign in to comment.