feat: add download info pane to TUI
Splits the downloads area 60/40 with a new info pane that adapts to the selected download's status: header (filename, user, size, status, save path, bitrate, length) plus queued-specific fields (queue position, peer slots, peer upload speed) or live progress/speed/ETA when transferring. Plumbs queue position via a new ClientOperation::PlaceInQueueUpdate so PlaceInQueueResponse messages from peers reach DownloadStore, and threads search-time metadata (bitrate, length, peer slots/speed) onto Download through a new download_with_metadata entry point.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
pub mod logger;
|
||||
pub mod lock;
|
||||
pub mod md5;
|
||||
pub mod path;
|
||||
pub mod thread_pool;
|
||||
pub mod zlib;
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn expand_tilde(path: &str) -> PathBuf {
|
||||
if let Some(stripped) = path.strip_prefix('~')
|
||||
&& let Ok(home) = std::env::var("HOME")
|
||||
{
|
||||
return PathBuf::from(home).join(stripped.trim_start_matches('/'));
|
||||
}
|
||||
PathBuf::from(path)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn no_tilde_returned_as_is() {
|
||||
assert_eq!(expand_tilde("/abs/path"), PathBuf::from("/abs/path"));
|
||||
assert_eq!(expand_tilde("rel/path"), PathBuf::from("rel/path"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tilde_expanded_when_home_set() {
|
||||
// SAFETY: tests run single-threaded by default in this crate; if you
|
||||
// ever run with --test-threads >1 this needs serialization.
|
||||
unsafe {
|
||||
std::env::set_var("HOME", "/home/test");
|
||||
}
|
||||
assert_eq!(expand_tilde("~"), PathBuf::from("/home/test"));
|
||||
assert_eq!(
|
||||
expand_tilde("~/Downloads"),
|
||||
PathBuf::from("/home/test/Downloads")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user