Fix wrong estimated time when doing sync.
authoralex-z <blackslayer4@gmail.com>
Tue, 6 Sep 2022 11:36:29 +0000 (14:36 +0300)
committerallexzander <blackslayer4@gmail.com>
Wed, 7 Sep 2022 06:31:05 +0000 (09:31 +0300)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/gui/folderstatusmodel.cpp
src/gui/folderstatusmodel.h

index 51bbe4f748406e5b5f4071498adb5032818f0493..80080acc5dbac2a433f4bdd91a8dbd68cfb67e8b 100644 (file)
@@ -963,6 +963,10 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
 
     auto *pi = &_folders[folderIndex]._progress;
 
+    if (progress.status() == ProgressInfo::Starting) {
+        _isSyncRunningForAwhile = false;
+    }
+
     QVector<int> roles;
     roles << FolderStatusDelegate::SyncProgressItemString
           << FolderStatusDelegate::WarningCount
@@ -1086,13 +1090,23 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
         QString s1 = Utility::octetsToString(completedSize);
         QString s2 = Utility::octetsToString(totalSize);
 
-        if (progress.trustEta()) {
+        const auto estimatedEta = progress.totalProgress().estimatedEta;
+
+        if (progress.trustEta() && (estimatedEta > 0 || _isSyncRunningForAwhile)) {
+            _isSyncRunningForAwhile = true;
             //: Example text: "5 minutes left, 12 MB of 345 MB, file 6 of 7"
-            overallSyncString = tr("%5 left, %1 of %2, file %3 of %4")
-                                    .arg(s1, s2)
-                                    .arg(currentFile)
-                                    .arg(totalFileCount)
-                                    .arg(Utility::durationToDescriptiveString1(progress.totalProgress().estimatedEta));
+            if (estimatedEta == 0) {
+                overallSyncString = tr("A few seconds left, %1 of %2, file %3 of %4")
+                                        .arg(s1, s2)
+                                        .arg(currentFile)
+                                        .arg(totalFileCount);
+            } else {
+                overallSyncString = tr("%5 left, %1 of %2, file %3 of %4")
+                                        .arg(s1, s2)
+                                        .arg(currentFile)
+                                        .arg(totalFileCount)
+                                        .arg(Utility::durationToDescriptiveString1(estimatedEta));
+            }
 
         } else {
             //: Example text: "12 MB of 345 MB, file 6 of 7"
index 896a19550bdee116f43c56e3e8cd48ce56215099..9896d5644efc8af1577528fcec4b46164399c46e 100644 (file)
@@ -147,6 +147,8 @@ private:
     const AccountState *_accountState = nullptr;
     bool _dirty = false; // If the selective sync checkboxes were changed
 
+    bool _isSyncRunningForAwhile = false;
+
     /**
      * Keeps track of items that are fetching data from the server.
      *