Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.6] Fix wrong estimated time when doing sync. #4907

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/gui/folderstatusmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/gui/folderstatusmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ private slots:
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.
*
Expand Down