mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-15 02:01:38 +03:00
Time estimation: Use a consistent check for size dependence. #2328
This commit is contained in:
parent
509b83e73e
commit
7d68c628db
4 changed files with 21 additions and 14 deletions
|
@ -631,7 +631,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
||||||
qint64 curItemProgress = -1; // -1 means finished
|
qint64 curItemProgress = -1; // -1 means finished
|
||||||
quint64 biggerItemSize = -1;
|
quint64 biggerItemSize = -1;
|
||||||
foreach(const Progress::Info::ProgressItem &citm, progress._currentItems) {
|
foreach(const Progress::Info::ProgressItem &citm, progress._currentItems) {
|
||||||
if (curItemProgress == -1 || (Progress::isSizeDependent(citm._item._instruction)
|
if (curItemProgress == -1 || (Progress::isSizeDependent(citm._item)
|
||||||
&& biggerItemSize < citm._item._size)) {
|
&& biggerItemSize < citm._item._size)) {
|
||||||
curItemProgress = citm._completedSize;
|
curItemProgress = citm._completedSize;
|
||||||
curItem = citm._item;
|
curItem = citm._item;
|
||||||
|
@ -648,7 +648,7 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
||||||
|
|
||||||
|
|
||||||
QString fileProgressString;
|
QString fileProgressString;
|
||||||
if (Progress::isSizeDependent(curItem._instruction)) {
|
if (Progress::isSizeDependent(curItem)) {
|
||||||
QString s1 = Utility::octetsToString( curItemProgress );
|
QString s1 = Utility::octetsToString( curItemProgress );
|
||||||
QString s2 = Utility::octetsToString( curItem._size );
|
QString s2 = Utility::octetsToString( curItem._size );
|
||||||
quint64 estimatedBw = progress.getFileEstimate(curItem).getEstimatedBandwidth();
|
quint64 estimatedBw = progress.getFileEstimate(curItem).getEstimatedBandwidth();
|
||||||
|
|
|
@ -224,7 +224,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo
|
||||||
icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
|
icon = Theme::instance()->syncStateIcon(SyncResult::Problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Progress::isSizeDependent(item._instruction)) {
|
if (Progress::isSizeDependent(item)) {
|
||||||
columns << Utility::octetsToString( item._size );
|
columns << Utility::octetsToString( item._size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,12 @@ namespace OCC {
|
||||||
namespace Progress
|
namespace Progress
|
||||||
{
|
{
|
||||||
/** Return true is the size need to be taken in account in the total amount of time */
|
/** Return true is the size need to be taken in account in the total amount of time */
|
||||||
inline bool isSizeDependent(csync_instructions_e instruction) {
|
static inline bool isSizeDependent(const SyncFileItem & item)
|
||||||
return instruction == CSYNC_INSTRUCTION_CONFLICT || instruction == CSYNC_INSTRUCTION_SYNC
|
{
|
||||||
|| instruction == CSYNC_INSTRUCTION_NEW;
|
return ! item._isDirectory && (
|
||||||
|
item._instruction == CSYNC_INSTRUCTION_CONFLICT
|
||||||
|
|| item._instruction == CSYNC_INSTRUCTION_SYNC
|
||||||
|
|| item._instruction == CSYNC_INSTRUCTION_NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +53,13 @@ namespace Progress
|
||||||
quint64 _completedSize;
|
quint64 _completedSize;
|
||||||
// Should this be in a separate file?
|
// Should this be in a separate file?
|
||||||
struct EtaEstimate {
|
struct EtaEstimate {
|
||||||
EtaEstimate() : _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0),_sampleCount(1) {}
|
EtaEstimate()
|
||||||
|
: _startedTime(QDateTime::currentMSecsSinceEpoch())
|
||||||
|
, _agvEtaMSecs(0)
|
||||||
|
, _effectivProgressPerSec(0)
|
||||||
|
, _sampleCount(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static const int MAX_AVG_DIVIDER=60;
|
static const int MAX_AVG_DIVIDER=60;
|
||||||
static const int INITAL_WAIT_TIME=5;
|
static const int INITAL_WAIT_TIME=5;
|
||||||
|
@ -115,11 +124,9 @@ namespace Progress
|
||||||
void setProgressComplete(const SyncFileItem &item) {
|
void setProgressComplete(const SyncFileItem &item) {
|
||||||
_currentItems.remove(item._file);
|
_currentItems.remove(item._file);
|
||||||
_completedFileCount += item._affectedItems;
|
_completedFileCount += item._affectedItems;
|
||||||
if (!item._isDirectory) {
|
if (Progress::isSizeDependent(item)) {
|
||||||
if (Progress::isSizeDependent(item._instruction)) {
|
|
||||||
_completedSize += item._size;
|
_completedSize += item._size;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_lastCompletedItem = item;
|
_lastCompletedItem = item;
|
||||||
this->updateEstimation();
|
this->updateEstimation();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +149,7 @@ namespace Progress
|
||||||
quint64 completedSize() const {
|
quint64 completedSize() const {
|
||||||
quint64 r = _completedSize;
|
quint64 r = _completedSize;
|
||||||
foreach(const ProgressItem &i, _currentItems) {
|
foreach(const ProgressItem &i, _currentItems) {
|
||||||
if (!i._item._isDirectory)
|
if (Progress::isSizeDependent(i._item))
|
||||||
r += i._completedSize;
|
r += i._completedSize;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -496,7 +496,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
||||||
|
|
||||||
if (!item->_isDirectory) {
|
if (!item->_isDirectory) {
|
||||||
_progressInfo._totalFileCount++;
|
_progressInfo._totalFileCount++;
|
||||||
if (Progress::isSizeDependent(file->instruction)) {
|
if (Progress::isSizeDependent(item)) {
|
||||||
_progressInfo._totalSize += file->size;
|
_progressInfo._totalSize += file->size;
|
||||||
}
|
}
|
||||||
} else if (file->instruction != CSYNC_INSTRUCTION_NONE) {
|
} else if (file->instruction != CSYNC_INSTRUCTION_NONE) {
|
||||||
|
|
Loading…
Reference in a new issue