Skip to content

Commit

Permalink
fix: handle when auto updater receives a non-200 from GitHub API (#351)
Browse files Browse the repository at this point in the history
Fixes #350

Co-authored-by: James VL <[email protected]>
  • Loading branch information
jamesvl and jamesvl committed Dec 22, 2023
1 parent e871f34 commit 3564971
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/next_ls/updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule NextLS.Updater do
retry = Keyword.get(opts, :retry, :safe)

case Req.get("/repos/elixir-tools/next-ls/releases/latest", base_url: api_host, retry: retry) do
{:ok, %{body: %{"tag_name" => "v" <> version = tag}}} ->
{:ok, %{status: 200, body: %{"tag_name" => "v" <> version = tag}}} ->
with {:ok, latest_version} <- Version.parse(version),
:gt <- Version.compare(latest_version, current_version) do
with :ok <- File.rename(binpath, binpath <> "-#{Version.to_string(current_version)}"),
Expand Down Expand Up @@ -65,7 +65,7 @@ defmodule NextLS.Updater do
end
end

{:error, error} ->
{_, error} ->
NextLS.Logger.error(
logger,
"Failed to retrieve the latest version number of Next LS from the GitHub API: #{inspect(error)}"
Expand Down

0 comments on commit 3564971

Please sign in to comment.