Loading adb/client/file_sync_client.cpp +15 −1 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,8 @@ #include <android-base/strings.h> #include <android-base/strings.h> #include <android-base/stringprintf.h> #include <android-base/stringprintf.h> using namespace std::literals; typedef void(sync_ls_cb)(unsigned mode, uint64_t size, uint64_t time, const char* name); typedef void(sync_ls_cb)(unsigned mode, uint64_t size, uint64_t time, const char* name); struct syncsendbuf { struct syncsendbuf { Loading Loading @@ -112,8 +114,12 @@ struct TransferLedger { uint64_t bytes_transferred; uint64_t bytes_transferred; uint64_t bytes_expected; uint64_t bytes_expected; bool expect_multiple_files; bool expect_multiple_files; private: std::string last_progress_str; std::string last_progress_str; std::chrono::steady_clock::time_point last_progress_time; public: TransferLedger() { TransferLedger() { Reset(); Reset(); } } Loading @@ -128,12 +134,13 @@ struct TransferLedger { } } void Reset() { void Reset() { last_progress_str.clear(); start_time = std::chrono::steady_clock::now(); start_time = std::chrono::steady_clock::now(); files_transferred = 0; files_transferred = 0; files_skipped = 0; files_skipped = 0; bytes_transferred = 0; bytes_transferred = 0; bytes_expected = 0; bytes_expected = 0; last_progress_str.clear(); last_progress_time = {}; } } std::string TransferRate() { std::string TransferRate() { Loading @@ -153,6 +160,12 @@ struct TransferLedger { void ReportProgress(LinePrinter& lp, const std::string& file, uint64_t file_copied_bytes, void ReportProgress(LinePrinter& lp, const std::string& file, uint64_t file_copied_bytes, uint64_t file_total_bytes) { uint64_t file_total_bytes) { static constexpr auto kProgressReportInterval = 100ms; auto now = std::chrono::steady_clock::now(); if (now < last_progress_time + kProgressReportInterval) { return; } char overall_percentage_str[5] = "?"; char overall_percentage_str[5] = "?"; if (bytes_expected != 0 && bytes_transferred <= bytes_expected) { if (bytes_expected != 0 && bytes_transferred <= bytes_expected) { int overall_percentage = static_cast<int>(bytes_transferred * 100 / bytes_expected); int overall_percentage = static_cast<int>(bytes_transferred * 100 / bytes_expected); Loading Loading @@ -186,6 +199,7 @@ struct TransferLedger { if (output != last_progress_str) { if (output != last_progress_str) { lp.Print(output, LinePrinter::LineType::INFO); lp.Print(output, LinePrinter::LineType::INFO); last_progress_str = std::move(output); last_progress_str = std::move(output); last_progress_time = now; } } } } Loading Loading
adb/client/file_sync_client.cpp +15 −1 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,8 @@ #include <android-base/strings.h> #include <android-base/strings.h> #include <android-base/stringprintf.h> #include <android-base/stringprintf.h> using namespace std::literals; typedef void(sync_ls_cb)(unsigned mode, uint64_t size, uint64_t time, const char* name); typedef void(sync_ls_cb)(unsigned mode, uint64_t size, uint64_t time, const char* name); struct syncsendbuf { struct syncsendbuf { Loading Loading @@ -112,8 +114,12 @@ struct TransferLedger { uint64_t bytes_transferred; uint64_t bytes_transferred; uint64_t bytes_expected; uint64_t bytes_expected; bool expect_multiple_files; bool expect_multiple_files; private: std::string last_progress_str; std::string last_progress_str; std::chrono::steady_clock::time_point last_progress_time; public: TransferLedger() { TransferLedger() { Reset(); Reset(); } } Loading @@ -128,12 +134,13 @@ struct TransferLedger { } } void Reset() { void Reset() { last_progress_str.clear(); start_time = std::chrono::steady_clock::now(); start_time = std::chrono::steady_clock::now(); files_transferred = 0; files_transferred = 0; files_skipped = 0; files_skipped = 0; bytes_transferred = 0; bytes_transferred = 0; bytes_expected = 0; bytes_expected = 0; last_progress_str.clear(); last_progress_time = {}; } } std::string TransferRate() { std::string TransferRate() { Loading @@ -153,6 +160,12 @@ struct TransferLedger { void ReportProgress(LinePrinter& lp, const std::string& file, uint64_t file_copied_bytes, void ReportProgress(LinePrinter& lp, const std::string& file, uint64_t file_copied_bytes, uint64_t file_total_bytes) { uint64_t file_total_bytes) { static constexpr auto kProgressReportInterval = 100ms; auto now = std::chrono::steady_clock::now(); if (now < last_progress_time + kProgressReportInterval) { return; } char overall_percentage_str[5] = "?"; char overall_percentage_str[5] = "?"; if (bytes_expected != 0 && bytes_transferred <= bytes_expected) { if (bytes_expected != 0 && bytes_transferred <= bytes_expected) { int overall_percentage = static_cast<int>(bytes_transferred * 100 / bytes_expected); int overall_percentage = static_cast<int>(bytes_transferred * 100 / bytes_expected); Loading Loading @@ -186,6 +199,7 @@ struct TransferLedger { if (output != last_progress_str) { if (output != last_progress_str) { lp.Print(output, LinePrinter::LineType::INFO); lp.Print(output, LinePrinter::LineType::INFO); last_progress_str = std::move(output); last_progress_str = std::move(output); last_progress_time = now; } } } } Loading