-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle local archives without requiring network tooling #65
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,7 @@ defmodule XLA do | |
end | ||
|
||
defp download_external!(url, archive_path) do | ||
assert_network_tool!() | ||
unless local_archive(url), do: assert_network_tool!() | ||
Logger.info("Downloading XLA archive from #{url}") | ||
download_archive!(url, archive_path) | ||
end | ||
|
@@ -242,6 +242,14 @@ defmodule XLA do | |
end | ||
|
||
defp download(url, dest) do | ||
if local_path = local_archive(url) do | ||
File.cp!(local_path, dest) | ||
else | ||
download_remote(url, dest) | ||
end | ||
end | ||
|
||
defp download_remote(url, dest) do | ||
command = | ||
case network_tool() do | ||
:curl -> "curl --fail -L -o #{dest} #{curl_options()} #{url}" | ||
|
@@ -296,4 +304,15 @@ defmodule XLA do | |
headers = http_headers() | ||
Enum.map_join(headers, " ", &"--header='#{&1}'") | ||
end | ||
|
||
defp local_archive("file:" <> rest) do | ||
case rest do | ||
"//localhost/" <> path -> "/" <> path | ||
"///" <> path -> "/" <> path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't support "file:///c:/foo/bar" on Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unable to test on Windows; we have to rewrite that to use backslashes, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that's not necessary, but you don't need to add a prefixing "/". Using a separate env var will be simpler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Indeed. 🙈 |
||
"/" <> path when binary_part(path, 0, 1) != "/" -> rest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should support this version. I can't see it on the spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it seems to be used by KDE. I am 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RFC 3986 mentions that:
|
||
_ -> nil | ||
end | ||
end | ||
|
||
defp local_archive(_), do: nil | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we don't support reading from any other host either, I would remove this version.