fix(tui): removed a ton of use_username_dirs references
feat(tui): username is now appended to download_dir before passed as parameter fix(tui): username is sanitized before appended to path
This commit is contained in:
@@ -1148,13 +1148,9 @@ fn main() {
|
||||
let completed = completed.clone();
|
||||
workers.push(std::thread::spawn(move || {
|
||||
Metrics::bump(&metrics.downloads_issued);
|
||||
let Ok((_download, status_rx)) = client.download(
|
||||
filename.clone(),
|
||||
peer.clone(),
|
||||
size,
|
||||
dir,
|
||||
false,
|
||||
) else {
|
||||
let Ok((_download, status_rx)) =
|
||||
client.download(filename.clone(), peer.clone(), size, dir)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let deadline = run_deadline;
|
||||
|
||||
@@ -99,14 +99,12 @@ impl Client {
|
||||
username: String,
|
||||
size: u64,
|
||||
download_directory: String,
|
||||
use_username_dirs: bool,
|
||||
) -> Result<(Download, Receiver<DownloadStatus>)> {
|
||||
self.download_with_metadata(
|
||||
filename,
|
||||
username,
|
||||
size,
|
||||
download_directory,
|
||||
use_username_dirs,
|
||||
DownloadMetadata::default(),
|
||||
)
|
||||
}
|
||||
@@ -117,7 +115,6 @@ impl Client {
|
||||
username: String,
|
||||
size: u64,
|
||||
download_directory: String,
|
||||
use_username_dirs: bool,
|
||||
metadata: DownloadMetadata,
|
||||
) -> Result<(Download, Receiver<DownloadStatus>)> {
|
||||
info!("[client] Downloading {} from {}", filename, username);
|
||||
@@ -135,7 +132,6 @@ impl Client {
|
||||
token,
|
||||
size,
|
||||
download_directory,
|
||||
use_username_dirs,
|
||||
status: DownloadStatus::Queued,
|
||||
sender: download_sender,
|
||||
queue_position: None,
|
||||
|
||||
@@ -23,7 +23,6 @@ fn download(
|
||||
token,
|
||||
size: 100,
|
||||
download_directory: "test".to_string(),
|
||||
use_username_dirs: false,
|
||||
status,
|
||||
sender,
|
||||
queue_position: None,
|
||||
|
||||
@@ -97,7 +97,6 @@ fn download_without_a_connection_resolves_failed() {
|
||||
"peer".to_string(),
|
||||
100,
|
||||
"test".to_string(),
|
||||
false,
|
||||
)
|
||||
.expect("download() should return a handle");
|
||||
assert!(matches!(
|
||||
|
||||
@@ -242,7 +242,6 @@ mod tests {
|
||||
token,
|
||||
size: 100,
|
||||
download_directory: "test".to_string(),
|
||||
use_username_dirs: false,
|
||||
status,
|
||||
sender: mpsc::channel().0,
|
||||
queue_position: None,
|
||||
|
||||
@@ -110,10 +110,6 @@ fn resolve_download_path(download: &Download) -> Result<String, DownloadError> {
|
||||
.to_path_buf();
|
||||
}
|
||||
|
||||
if download.use_username_dirs {
|
||||
expanded_path = expanded_path.join(download.username.as_str());
|
||||
}
|
||||
|
||||
let final_path =
|
||||
expanded_path.join(extract_filename_from_path(&download.filename));
|
||||
|
||||
@@ -639,7 +635,6 @@ mod tests {
|
||||
token: 1,
|
||||
size,
|
||||
download_directory: dir.display().to_string(),
|
||||
use_username_dirs: false,
|
||||
status: DownloadStatus::Queued,
|
||||
sender: mpsc::channel().0,
|
||||
queue_position: None,
|
||||
|
||||
@@ -479,7 +479,6 @@ mod tests {
|
||||
token,
|
||||
size: 100,
|
||||
download_directory: std::env::temp_dir().display().to_string(),
|
||||
use_username_dirs: false,
|
||||
status: DownloadStatus::Queued,
|
||||
sender: mpsc::channel().0,
|
||||
queue_position: None,
|
||||
|
||||
@@ -185,7 +185,6 @@ pub struct Download {
|
||||
pub token: u32,
|
||||
pub size: u64,
|
||||
pub download_directory: String,
|
||||
pub use_username_dirs: bool,
|
||||
pub status: DownloadStatus,
|
||||
pub sender: Sender<DownloadStatus>,
|
||||
pub queue_position: Option<u32>,
|
||||
|
||||
Reference in New Issue
Block a user