Progress: Don't display unlikely estimates #5046 (#5066)

This commit is contained in:
ckamm 2016-08-15 13:36:53 +02:00 коммит произвёл GitHub
Родитель 1a454ec6b2
Коммит 7b26e6b8f9
4 изменённых файлов: 65 добавлений и 21 удалений

Просмотреть файл

@ -934,11 +934,20 @@ void FolderStatusModel::slotSetProgress(const ProgressInfo &progress)
if (totalSize > 0) {
QString s1 = Utility::octetsToString( completedSize );
QString s2 = Utility::octetsToString( totalSize );
//: 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 (progress.trustEta()) {
//: 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) );
} else {
//: Example text: "12 MB of 345 MB, file 6 of 7"
overallSyncString = tr("%1 of %2, file %3 of %4")
.arg(s1, s2)
.arg(currentFile).arg(totalFileCount);
}
} else if (totalFileCount > 0) {
// Don't attempt to estimate the time left if there is no kb to transfer.
overallSyncString = tr("file %1 of %2") .arg(currentFile).arg(totalFileCount);

Просмотреть файл

@ -658,18 +658,29 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo&
} else if (progress.totalSize() == 0 ) {
quint64 currentFile = progress.currentFile();
quint64 totalFileCount = qMax(progress.totalFiles(), currentFile);
_actionStatus->setText( tr("Syncing %1 of %2 (%3 left)")
.arg( currentFile ).arg( totalFileCount )
.arg( Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta) ) );
QString msg;
if (progress.trustEta()) {
msg = tr("Syncing %1 of %2 (%3 left)")
.arg( currentFile ).arg( totalFileCount )
.arg( Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta) );
} else {
msg = tr("Syncing %1 of %2")
.arg( currentFile ).arg( totalFileCount );
}
_actionStatus->setText( msg );
} else {
QString totalSizeStr = Utility::octetsToString( progress.totalSize() );
_actionStatus->setText( tr("Syncing %1 (%2 left)")
.arg( totalSizeStr, Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta) ) );
QString msg;
if (progress.trustEta()) {
msg = tr("Syncing %1 (%2 left)")
.arg( totalSizeStr, Utility::durationToDescriptiveString2(progress.totalProgress().estimatedEta) );
} else {
msg = tr("Syncing %1")
.arg( totalSizeStr );
}
_actionStatus->setText( msg );
}
_actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
if (!progress._lastCompletedItem.isEmpty()

Просмотреть файл

@ -279,13 +279,6 @@ ProgressInfo::Estimates ProgressInfo::totalProgress() const
// assume the remaining transfer will be done with the highest speed
// we've seen.
// This assumes files and transfers finish as quickly as possible
// *but* note that maxPerSecond could be serious underestimates
// (if we never got to fully excercise transfer or files/second)
quint64 optimisticEta =
_fileProgress.remaining() / _maxFilesPerSecond * 1000
+ _sizeProgress.remaining() / _maxBytesPerSecond * 1000;
// Compute a value that is 0 when fps is <=L*max and 1 when fps is >=U*max
double fps = _fileProgress._progressPerSec;
double fpsL = 0.5;
@ -309,11 +302,26 @@ ProgressInfo::Estimates ProgressInfo::totalProgress() const
double beOptimistic = nearMaxFps * slowTransfer;
size.estimatedEta = (1.0 - beOptimistic) * size.estimatedEta
+ beOptimistic * optimisticEta;
+ beOptimistic * optimisticEta();
return size;
}
quint64 ProgressInfo::optimisticEta() const
{
// This assumes files and transfers finish as quickly as possible
// *but* note that maxPerSecond could be serious underestimate
// (if we never got to fully excercise transfer or files/second)
return _fileProgress.remaining() / _maxFilesPerSecond * 1000
+ _sizeProgress.remaining() / _maxBytesPerSecond * 1000;
}
bool ProgressInfo::trustEta() const
{
return totalProgress().estimatedEta < 100 * optimisticEta();
}
ProgressInfo::Estimates ProgressInfo::fileProgress(const SyncFileItem &item) const
{
return _currentItems[item._file]._progress.estimates();

Просмотреть файл

@ -164,6 +164,22 @@ public:
*/
Estimates totalProgress() const;
/**
* Get the optimistic eta.
*
* This value is based on the highest observed transfer bandwidth
* and files-per-second speed.
*/
quint64 optimisticEta() const;
/**
* Whether the remaining-time estimate is trusted.
*
* We don't trust it if it is hugely above the optimistic estimate.
* See #5046.
*/
bool trustEta() const;
/**
* Get the current file completion estimate structure
*/