Skip to content

Commit

Permalink
Extract rust_analyzer_filename and rename serverfile to `rust_ana…
Browse files Browse the repository at this point in the history
…lyzer_path`.
  • Loading branch information
azriel91 committed Nov 29, 2024
1 parent d06d9dd commit 1e6e80e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@ def install_or_update(cls) -> None:
extension = "zip" if is_windows else "gz"
url = URL.format(tag=TAG, arch=arch(), platform=platform(), ext=extension)
archive_file = os.path.join(cls.basedir(), f"rust-analyzer.{extension}")
serverfile = os.path.join(
cls.basedir(),
"rust-analyzer.exe" if is_windows else "rust-analyzer"
)
rust_analyzer_filename = "rust-analyzer.exe" if is_windows else "rust-analyzer"
rust_analyzer_path = os.path.join(cls.basedir(), rust_analyzer_filename)
with urllib.request.urlopen(url) as fp:
with open(archive_file, "wb") as f:
f.write(fp.read())
Expand All @@ -176,10 +174,10 @@ def install_or_update(cls) -> None:
zip_ref.extract("rust-analyzer.exe", cls.basedir())
else:
with gzip.open(archive_file, "rb") as fp:
with open(serverfile, "wb") as f:
with open(rust_analyzer_path, "wb") as f:
f.write(fp.read())
os.remove(archive_file)
os.chmod(serverfile, 0o744)
os.chmod(rust_analyzer_path, 0o744)
with open(os.path.join(cls.basedir(), "VERSION"), "w") as fp:
fp.write(version)
except BaseException:
Expand Down

0 comments on commit 1e6e80e

Please sign in to comment.