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:
Michel de Graaf
2026-09-06 21:40:45 +02:00
parent 7bc696cab6
commit aa61a1a434
38 changed files with 1139 additions and 102 deletions
@@ -177,6 +177,9 @@ fn build_info_lines(
}
DownloadStatus::Paused { .. } => ("Paused".to_string(), info_style()),
DownloadStatus::Completed => ("Completed".to_string(), success_style()),
DownloadStatus::Cancelled => {
("Cancelled".to_string(), inactive_style())
}
DownloadStatus::Failed(_) => ("Failed".to_string(), error_style()),
DownloadStatus::TimedOut => ("Timed out".to_string(), error_style()),
};
@@ -271,7 +274,9 @@ fn build_info_lines(
)));
}
}
DownloadStatus::Completed | DownloadStatus::TimedOut => {}
DownloadStatus::Completed
| DownloadStatus::Cancelled
| DownloadStatus::TimedOut => {}
}
lines
+4 -1
View File
@@ -81,6 +81,7 @@ pub fn render_downloads_pane(
)
}
DownloadStatus::Completed => "Completed".to_string(),
DownloadStatus::Cancelled => "Cancelled".to_string(),
DownloadStatus::Failed(_) => "Failed".to_string(),
DownloadStatus::TimedOut => "Timed out".to_string(),
};
@@ -97,7 +98,9 @@ pub fn render_downloads_pane(
DownloadStatus::Failed(_) | DownloadStatus::TimedOut => {
error_style()
}
DownloadStatus::Queued => inactive_style(),
DownloadStatus::Queued | DownloadStatus::Cancelled => {
inactive_style()
}
_ => primary_style(),
};
+3 -1
View File
@@ -8,7 +8,9 @@ mod searches_pane;
pub use browse_pane::render_browse_pane;
pub use chat_pane::render_chat_pane;
pub use download_info_pane::{render_download_info_pane, selected_transfer};
pub use download_info_pane::{
SelectedTransfer, render_download_info_pane, selected_transfer,
};
pub use downloads_pane::render_downloads_pane;
pub use results_pane::{ResultsPaneParams, render_results_pane};
pub use rooms_pane::render_rooms_pane;