diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index cd4897f775..534efca7e0 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -64,13 +64,15 @@ FileOperationProgressWidget::FileOperationProgressWidget(NonnullRefPtr= 6); + VERIFY(parts.size() >= 8); did_progress( parts[3].to_uint().value_or(0), parts[4].to_uint().value_or(0), parts[1].to_uint().value_or(0), parts[2].to_uint().value_or(0), - parts[5]); + parts[5].to_uint().value_or(0), + parts[6].to_uint().value_or(0), + parts[7]); } }; } @@ -94,7 +96,7 @@ void FileOperationProgressWidget::did_error() window()->close(); } -void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, const StringView& current_file_name) +void FileOperationProgressWidget::did_progress([[maybe_unused]] off_t bytes_done, [[maybe_unused]] off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, const StringView& current_file_name) { auto& current_file_label = *find_descendant_of_type_named("current_file_label"); auto& current_file_progress_bar = *find_descendant_of_type_named("current_file_progress_bar"); @@ -102,8 +104,8 @@ void FileOperationProgressWidget::did_progress(off_t bytes_done, off_t total_byt auto& overall_progress_bar = *find_descendant_of_type_named("overall_progress_bar"); current_file_label.set_text(current_file_name); - current_file_progress_bar.set_max(total_byte_count); - current_file_progress_bar.set_value(bytes_done); + current_file_progress_bar.set_max(current_file_size); + current_file_progress_bar.set_value(current_file_done); overall_progress_label.set_text(String::formatted("{} of {}", files_done, total_file_count)); overall_progress_bar.set_max(total_file_count); diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.h b/Userland/Applications/FileManager/FileOperationProgressWidget.h index 4efbbb19d7..8c47b67bfd 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.h +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.h @@ -41,7 +41,7 @@ private: void did_finish(); void did_error(); - void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, const StringView& current_file_name); + void did_progress(off_t bytes_done, off_t total_byte_count, size_t files_done, size_t total_file_count, off_t current_file_done, off_t current_file_size, const StringView& current_file_name); void close_pipe(); diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp index 719905d84f..28a32649c0 100644 --- a/Userland/Services/FileOperation/main.cpp +++ b/Userland/Services/FileOperation/main.cpp @@ -120,8 +120,9 @@ int perform_copy(const String& source, const String& destination) for (size_t i = 0; i < items.size(); ++i) { auto& item = items[i]; + off_t item_done = 0; auto print_progress = [&] { - outln("PROGRESS {} {} {} {} {}", i, items.size(), bytes_copied_so_far, total_bytes_to_copy, item.source); + outln("PROGRESS {} {} {} {} {} {} {}", i, items.size(), bytes_copied_so_far, total_bytes_to_copy, item_done, item.size, item.source); }; if (item.type == WorkItem::Type::CreateDirectory) { outln("MKDIR {}", item.destination); @@ -146,6 +147,7 @@ int perform_copy(const String& source, const String& destination) auto& destination_file = *destination_file_or_error.value(); while (true) { + print_progress(); auto buffer = source_file.read(65536); if (buffer.is_null()) break; @@ -153,6 +155,7 @@ int perform_copy(const String& source, const String& destination) warnln("Failed to write to destination file: {}", destination_file.error_string()); return 1; } + item_done += buffer.size(); bytes_copied_so_far += buffer.size(); print_progress(); // FIXME: Remove this once the kernel is smart enough to schedule other threads