Remove leftovers in case assets extraction fails (#1020)

This commit is contained in:
Jonatan Kłosko 2022-02-22 01:01:04 +01:00 committed by GitHub
parent 3f872816ee
commit ca0128d028
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1307,7 +1307,14 @@ defmodule Livebook.Session do
end
defp extract_archive!(binary, path) do
:ok = :erl_tar.extract({:binary, binary}, [:compressed, {:cwd, String.to_charlist(path)}])
case :erl_tar.extract({:binary, binary}, [:compressed, {:cwd, String.to_charlist(path)}]) do
:ok ->
:ok
{:error, reason} ->
File.rm_rf!(path)
raise "failed to extract archive to #{path}, reason: #{inspect(reason)}"
end
end
@doc """