Use `with` form properly

new-login
Marcin Kulik 7 years ago
parent 6c36e0de43
commit 1912534ae9

@ -19,9 +19,8 @@ defmodule Asciinema.FileStore do
@behaviour Asciinema.FileStore
def download_file(store_path, local_path) do
case open_file(store_path, &(:file.copy(&1, local_path))) do
{:ok, {:ok, _}} -> :ok
otherwise -> otherwise
with {:ok, {:ok, _}} <- open_file(store_path, &(:file.copy(&1, local_path))) do
:ok
end
end
end

@ -6,8 +6,6 @@ defmodule Asciinema.FileStore.Cached do
with :ok <- remote_store().put_file(dst_path, src_local_path, content_type, compress),
:ok <- cache_store().put_file(dst_path, src_local_path, content_type, compress) do
:ok
else
otherwise -> otherwise
end
end
@ -25,8 +23,6 @@ defmodule Asciinema.FileStore.Cached do
:ok <- cache_store().put_file(path, tmp_path, MIME.path(path)),
:ok <- File.rm(tmp_path) do
cache_store().open_file(path, function)
else
otherwise -> otherwise
end
otherwise ->
otherwise

@ -14,9 +14,8 @@ defmodule Asciinema.FileStore.S3 do
{body, opts}
end
case make_request(S3.put_object(bucket(), base_path() <> dst_path, body, opts)) do
{:ok, _} -> :ok
otherwise -> otherwise
with {:ok, _} <- make_request(S3.put_object(bucket(), base_path() <> dst_path, body, opts)) do
:ok
end
end

Loading…
Cancel
Save