Skip to content

Commit

Permalink
File doesn't support rename across file systems.
Browse files Browse the repository at this point in the history
It's stricly rename, not the mv equivalent.
So we need to use a copy and delete.
  • Loading branch information
bahner committed Feb 12, 2024
1 parent 57cf8c5 commit 4170ae2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ex_ipfs/get.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ defmodule ExIpfs.Get do
IO.binwrite(fd, get.content)

if get.archive do
File.rename!(tmp, get.fspath)
File.cp!(tmp, get.fspath)
File.rm!(tmp)
{:ok, get.fspath}
else
extract_elem_from_tar_to(tmp, get.name, get.fspath)
Expand All @@ -79,7 +80,8 @@ defmodule ExIpfs.Get do
with cwd when is_bitstring(cwd) <- Temp.path!(parent_tmp_dir),
extract_result <- :erl_tar.extract(file, [{:cwd, ~c'#{cwd}'}]) do
if :ok == extract_result do
File.rename!("#{cwd}/#{elem}", output)
File.cp!("#{cwd}/#{elem}", output)
File.rm!("#{cwd}/#{elem}")
:ok
end
end
Expand Down

0 comments on commit 4170ae2

Please sign in to comment.