Downloads a file once into the cache directory and gives its local path.
{:ok, path} = TuningFork.Sample.Fetch.fetch("https://example.org/kick.wav")
:ok = TuningFork.Sample.Fetch.prefetch(urls)
Summary
Functions
Start fun under key in the background unless one is already running; return at once.
Whether url is already in the cache.
Where fetched files are kept.
The local path of url, fetched if it is not in the cache yet. A fetch of the same URL
already under way is waited for rather than repeated.
Fetch the body of url. Spaces and other characters a URL cannot carry are percent-encoded; what is already percent-encoded is left as it is.
Run fun in a task registered under key, or wait for the one already running under
that key, and return when it is done.
Start fetching every URL not yet in the cache, one after another in the background, and return at once. A list already being walked is not walked again.
Wait until every fetch and background task under way has finished.
Functions
Start fun under key in the background unless one is already running; return at once.
Whether url is already in the cache.
@spec dir() :: Path.t()
Where fetched files are kept.
The local path of url, fetched if it is not in the cache yet. A fetch of the same URL
already under way is waited for rather than repeated.
The cache is $XDG_CACHE_HOME/tuning_fork/samples, or ~/.cache/tuning_fork/samples.
{:error, reason} when the fetch fails or the cache cannot be written.
Fetch the body of url. Spaces and other characters a URL cannot carry are percent-encoded; what is already percent-encoded is left as it is.
Run fun in a task registered under key, or wait for the one already running under
that key, and return when it is done.
@spec prefetch([String.t()]) :: :ok
Start fetching every URL not yet in the cache, one after another in the background, and return at once. A list already being walked is not walked again.
@spec settle() :: :ok
Wait until every fetch and background task under way has finished.