diff --git a/lib/asciinema/file_store.ex b/lib/asciinema/file_store.ex index cf00ee2..56c71a3 100644 --- a/lib/asciinema/file_store.ex +++ b/lib/asciinema/file_store.ex @@ -6,17 +6,17 @@ defmodule Asciinema.FileStore do @callback serve_file(conn :: %Plug.Conn{}, path :: String.t, filename :: String.t) :: %Plug.Conn{} @doc "Opens the given path in store" - @callback open(path :: String.t) :: {:ok, File.io_device} | {:error, File.posix} + @callback open_file(path :: String.t) :: {:ok, File.io_device} | {:error, File.posix} @doc "Opens the given path in store, executes given fn and closes the file" - @callback open(path :: String.t, function :: (File.io_device -> res)) :: {:ok, res} | {:error, File.posix} when res: var + @callback open_file(path :: String.t, function :: (File.io_device -> res)) :: {:ok, res} | {:error, File.posix} when res: var def put_file(dst_path, src_local_path, content_type) do instance().put_file(dst_path, src_local_path, content_type) end def open_file(path, f) do - instance().open(path, f) + instance().open_file(path, f) end def download_file(store_path, local_path) do diff --git a/lib/asciinema/file_store/local.ex b/lib/asciinema/file_store/local.ex index 69225d1..4cdce4e 100644 --- a/lib/asciinema/file_store/local.ex +++ b/lib/asciinema/file_store/local.ex @@ -29,10 +29,10 @@ defmodule Asciinema.FileStore.Local do |> halt end - def open(path) do + def open_file(path) do File.open(base_path() <> path, [:binary, :read]) end - def open(path, function) do + def open_file(path, function) do File.open(base_path() <> path, [:binary, :read], function) end diff --git a/lib/asciinema/file_store/s3.ex b/lib/asciinema/file_store/s3.ex index fac1d78..42d6c4c 100644 --- a/lib/asciinema/file_store/s3.ex +++ b/lib/asciinema/file_store/s3.ex @@ -25,7 +25,7 @@ defmodule Asciinema.FileStore.S3 do |> redirect(external: url) end - def open(path, function \\ nil) do + def open_file(path, function \\ nil) do response = S3.get_object(bucket(), base_path() <> path) |> ExAws.request(region: region()) # TODO: use make_request diff --git a/lib/asciinema/png_generator/a2png.ex b/lib/asciinema/png_generator/a2png.ex index 66bc65d..0cccd9e 100644 --- a/lib/asciinema/png_generator/a2png.ex +++ b/lib/asciinema/png_generator/a2png.ex @@ -65,7 +65,7 @@ defmodule Asciinema.PngGenerator.A2png do Integer.to_string(png_params.scale) ] - {:ok, {:ok, _}} = file_store().open(path, &(:file.copy(&1, json_path))) + :ok = file_store().download_file(path, json_path) process = Porcelain.spawn(bin_path(), args, err: :string) case Porcelain.Process.await(process, @a2png_timeout) do