Skip to content

Commit

Permalink
Merge pull request #147 from Glutexo/raw
Browse files Browse the repository at this point in the history
🚚 Append .raw to the downloaded file name
  • Loading branch information
Glutexo authored May 20, 2023
2 parents f2c4aa4 + 56fed27 commit efdf68a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Config

config(:onigumo, :input_path, "urls.txt")
config(:onigumo, :downloaded_suffix, ".raw")

env = config_env()
import_config("#{env}.exs")
3 changes: 2 additions & 1 deletion lib/onigumo/downloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ defmodule Onigumo.Downloader do
end

def create_file_name(url) do
Onigumo.Utilities.Hash.md5(url, :hex)
suffix = Application.get_env(:onigumo, :downloaded_suffix)
Onigumo.Utilities.Hash.md5(url, :hex) <> suffix
end

defp http_client() do
Expand Down
5 changes: 4 additions & 1 deletion test/onigumo_downloader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ defmodule OnigumoDownloaderTest do
input_url = "https://onigumo.local/hello.html"
created_file_name = Onigumo.Downloader.create_file_name(input_url)

expected_file_name = Onigumo.Utilities.Hash.md5(input_url, :hex)
input_url_hash = Onigumo.Utilities.Hash.md5(input_url, :hex)
suffix = Application.get_env(:onigumo, :downloaded_suffix)
expected_file_name = input_url_hash <> suffix

assert(created_file_name == expected_file_name)
end
end
Expand Down

0 comments on commit efdf68a

Please sign in to comment.