mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
FileManager+FileOperation: Show byte progress of current file
What I meant for the GUI progress bars to show: - Bytes copied of the current file - Files copied of the total set What it actually showed: - Bytes copied of the total bytes - Files copied of the total set This patch fixes it by showing byte progress of the current file instead of byte progress of total bytes.
This commit is contained in:
parent
1ca22b46f9
commit
bf1ef6533c
Notes:
sideshowbarker
2024-07-18 20:26:22 +09:00
Author: https://github.com/awesomekling
Commit: bf1ef6533c
3 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue