pub struct ActiveOutputRegistry { /* private fields */ }Expand description
Process-wide registry of output paths that are currently being written by active downloads.
All download command types (DownloadCommand, MetalinkDownloadCommand,
ConcurrentDownloadCommand) consult this registry before opening their disk writer,
so that concurrent downloads targeting the same filename receive distinct paths.
Implementations§
Source§impl ActiveOutputRegistry
impl ActiveOutputRegistry
Sourcepub async fn resolve(&self, desired: &Path) -> PathBuf
pub async fn resolve(&self, desired: &Path) -> PathBuf
Resolve the final output path for a download, registering it to prevent collisions.
If desired is not currently claimed by another active download, it is registered
and returned as-is. If a collision is detected, the method appends (1), (2),
etc. (before the file extension) until an unused name is found.
§Returns
The resolved PathBuf that the caller should use for all subsequent disk I/O.
The caller must call Self::release when the download finishes (success or failure).
Sourcepub async fn release(&self, path: &Path)
pub async fn release(&self, path: &Path)
Release a previously-resolved path from the registry.
Must be called when a download completes (success or failure) so that the path becomes available for future downloads if needed.