feat: add backup progress estimation with time remaining
- Add estimate_backup_size() using du -sb before rsync starts - Parse transfer speed from rsync output (KB/s, MB/s, GB/s) - Calculate remaining time based on speed and remaining bytes - Show estimated time remaining and size progress in UI - Add format_time_remaining() for human-readable time display - New UI elements: backup_time_label_ and backup_size_label_
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include "config.h"
|
||||
|
||||
struct RsyncProgress {
|
||||
@@ -13,6 +14,9 @@ struct RsyncProgress {
|
||||
int64_t bytes_transferred = 0;
|
||||
int64_t bytes_total = 0;
|
||||
int speed = 0;
|
||||
int64_t estimated_total_size = 0;
|
||||
double elapsed_seconds = 0;
|
||||
double estimated_remaining = 0;
|
||||
std::string current_file;
|
||||
std::string log_line;
|
||||
bool finished = false;
|
||||
@@ -43,6 +47,9 @@ public:
|
||||
|
||||
std::function<void(const RsyncProgress&)> on_progress;
|
||||
|
||||
int64_t estimate_backup_size(const std::string& source);
|
||||
std::string format_time_remaining(double seconds);
|
||||
|
||||
private:
|
||||
Config& config_;
|
||||
std::atomic<bool> running_{false};
|
||||
@@ -50,6 +57,7 @@ private:
|
||||
std::thread worker_;
|
||||
std::mutex log_mutex_;
|
||||
std::vector<std::string> log_buffer_;
|
||||
std::chrono::steady_clock::time_point start_time_;
|
||||
|
||||
std::vector<std::string> build_exclude_args();
|
||||
bool run_rsync(const std::vector<std::string>& args);
|
||||
|
||||
Reference in New Issue
Block a user