feat: cancel a download from the TUI, the CLI, and the daemon
Closes #54. A download can now be cancelled whether it is queued, in progress, or paused. Cancelled is a terminal status: the store refuses to overwrite it, the status channel relays nothing after it, the partial file is deleted, and the transfer thread releases its socket at its next one-second poll instead of the 30s read deadline. A queued download that is cancelled declines the peer's later offer with TransferResponse "Cancelled", and an inbound file connection for it is refused. A fresh download of the same file evicts the dead row so it is not shadowed, and a cancelled transfer is not re-queued after a restart. Surfaces: Client::cancel_download, download.cancel over RPC, `transfer cancel <user> <path>` on the CLI (which also stops an upload by that name), and x in the transfers pane, where d dismisses the row.
This commit is contained in:
@@ -152,6 +152,7 @@ pub fn download_status_glyph(status: &DownloadStatus) -> (&'static str, Style) {
|
||||
DownloadStatus::InProgress { .. } => (GLYPH_ACTIVE, accent_style()),
|
||||
DownloadStatus::Paused { .. } => (GLYPH_PAUSED, info_style()),
|
||||
DownloadStatus::Completed => (GLYPH_DONE, success_style()),
|
||||
DownloadStatus::Cancelled => (GLYPH_FAILED, inactive_style()),
|
||||
DownloadStatus::Failed(_) => (GLYPH_FAILED, error_style()),
|
||||
DownloadStatus::TimedOut => (GLYPH_TIMED_OUT, error_style()),
|
||||
}
|
||||
@@ -237,6 +238,7 @@ mod tests {
|
||||
(DownloadStatus::Completed, GLYPH_DONE, PHOSPHOR),
|
||||
(DownloadStatus::Failed(None), GLYPH_FAILED, ALARM),
|
||||
(DownloadStatus::TimedOut, GLYPH_TIMED_OUT, ALARM),
|
||||
(DownloadStatus::Cancelled, GLYPH_FAILED, COLOR_INACTIVE),
|
||||
] {
|
||||
let (got_glyph, style) = download_status_glyph(&status);
|
||||
assert_eq!(got_glyph, glyph);
|
||||
|
||||
Reference in New Issue
Block a user