Runtime supervisor and operations layer behind ElixirTorrent.
Most callers should use ElixirTorrent directly. This module is published in
HexDocs for API completeness — it owns the dynamic supervisor that starts torrent
processes and implements remove/2, stop_and_serialize/1, and related lifecycle
helpers.
Summary
Functions
Starts a new torrent download from a local .torrent path.
Returns info hashes for all active torrent processes.
Stops a running torrent and removes it from the active list.
Returns a default set of runtime stats for a torrent process.
Returns selected runtime fields for a torrent process as a map keyed by field.
Stops every active torrent and persists session state for each one.
Gracefully stops a torrent and persists session state.
Functions
@spec download( Path.t(), keyword() ) :: DynamicSupervisor.on_start_child()
Starts a new torrent download from a local .torrent path.
Options:
:download_dir— base directory for downloaded files (defaults toFile.cwd!/0)
Multi-file torrents with loose top-level files are written under a folder named after the torrent; torrents that already share a root folder keep their original paths.
Returns {:ok, pid} on success.
@spec list() :: [binary()]
Returns info hashes for all active torrent processes.
Stops a running torrent and removes it from the active list.
When :delete_data is true, downloaded files are deleted from disk after
the torrent process has been stopped.
Returns a default set of runtime stats for a torrent process.
The default fields are:
[:name, :speed, :downloaded, :bytes_size].
Returns selected runtime fields for a torrent process as a map keyed by field.
Example:
Torrents.stats(pid, [:name, :speed, :downloaded, :bytes_size])
@spec stop_all_and_serialize() :: :ok
Stops every active torrent and persists session state for each one.
Gracefully stops a torrent and persists session state.
Order of operations:
- Stop active piece downloads
- Disconnect all peers (BEP 3 messages, then TCP close)
- Tracker announce with
event=stopped - Write session to
.elixir_torrent/state/{hash}.term - Stop the torrent OTP process
Returns :ok when the torrent is not found (already stopped).