From 51de925d5494bc9e863a16eb6f1738be63c91ede Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Mon, 22 Jan 2024 17:31:58 +0100 Subject: [PATCH] "fix" upload count not tracking right --- common/src/upload_file_channel.rs | 2 +- .../manager/commands/constellation_commands.rs | 8 +++++++- ui/src/layouts/storage/functions.rs | 8 +++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/src/upload_file_channel.rs b/common/src/upload_file_channel.rs index ef04934b2bf..dc215088b45 100644 --- a/common/src/upload_file_channel.rs +++ b/common/src/upload_file_channel.rs @@ -11,7 +11,7 @@ pub enum UploadFileAction { Cancelling, UploadFiles(Vec), Uploading((String, String, String)), - Finishing, + Finishing(PathBuf, bool), Finished(T), Error, } diff --git a/common/src/warp_runner/manager/commands/constellation_commands.rs b/common/src/warp_runner/manager/commands/constellation_commands.rs index e46c8abbbc2..aa28e1cbc4e 100644 --- a/common/src/warp_runner/manager/commands/constellation_commands.rs +++ b/common/src/warp_runner/manager/commands/constellation_commands.rs @@ -511,6 +511,12 @@ async fn handle_upload_progress( percentage_number as usize ) } + // ConstellationProgressStream only ends (atm) when all files in the queue are done uploading + // This causes pending file count to not be updated which is way we send a message here too + if current_percentage == 100 { + let _ = tx_upload_file + .send(UploadFileAction::Finishing(file_path.clone(), false)); + } } } Progression::ProgressComplete { name, total } => { @@ -589,7 +595,7 @@ async fn handle_upload_progress( } }; } - let _ = tx_upload_file.send(UploadFileAction::Finishing); + let _ = tx_upload_file.send(UploadFileAction::Finishing(file_path, true)); log::info!("{:?} file uploaded!", filename); } diff --git a/ui/src/layouts/storage/functions.rs b/ui/src/layouts/storage/functions.rs index 3b4133278de..5316d1723da 100644 --- a/ui/src/layouts/storage/functions.rs +++ b/ui/src/layouts/storage/functions.rs @@ -553,10 +553,12 @@ pub fn start_upload_file_listener( upload_progress_bar::change_progress_percentage(&window, progress.clone()); upload_progress_bar::change_progress_description(&window, msg); } - UploadFileAction::Finishing => { + UploadFileAction::Finishing(file, finish) => { *files_been_uploaded.write_silent() = true; - if !files_in_queue_to_upload.read().is_empty() { - files_in_queue_to_upload.with_mut(|i| i.remove(0)); + if !files_in_queue_to_upload.read().is_empty() + && (finish || files_in_queue_to_upload.read().len() > 1) + { + files_in_queue_to_upload.with_mut(|i| i.retain(|p| !p.eq(&file))); upload_progress_bar::update_files_queue_len( &window, files_in_queue_to_upload.read().len(),