Skip to content

Commit

Permalink
Add more logs in RecordingConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
Rados13 committed Mar 18, 2024
1 parent f1780d8 commit e14f65a
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions lib/recording_converter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,14 @@ defmodule RecordingConverter do
end

defp send_files_without_index() do
{_succeses, failures} =
files =
output_directory()
|> File.ls!()

Logger.info("Files to send: #{files}")

{_succeses, failures} =
files
|> Enum.reject(&String.ends_with?(&1, @index_file))
|> Enum.map(&send_file(&1))
|> Enum.split_with(fn
Expand Down Expand Up @@ -123,9 +128,20 @@ defmodule RecordingConverter do
end

defp check_s3_bucket_and_local_equals?(objects) do
result? = output_directory() |> File.ls!() |> MapSet.new() == objects |> MapSet.new()
local_files = output_directory() |> File.ls!()

remote_files = MapSet.new(objects)

unless result?, do: Logger.error("Files on bucket and locally are not the same")
result? =
local_files
|> MapSet.new()
|> MapSet.equal?(remote_files)

unless result?,
do:
Logger.error(
"Files on bucket and locally are not the same, \nlocal: #{local_files},\nremote: #{objects}"
)

result?
end
Expand All @@ -134,10 +150,15 @@ defmodule RecordingConverter do
bucket = bucket_name()
file_path = Path.join(output_directory(), file_name)

file_path
|> S3.Upload.stream_file()
|> S3.upload(bucket, file_path)
|> ExAws.request()
result =
file_path
|> S3.Upload.stream_file()
|> S3.upload(bucket, file_path)
|> ExAws.request()

Logger.info("Send file #{file_path} to remote_path: #{file_path}, result: #{inspect(result)}")

result
end

defp terminate(status_code) do
Expand Down

0 comments on commit e14f65a

Please sign in to comment.