Skip to content

Commit

Permalink
Bugfix. Take root folder's files size into account when displaying th…
Browse files Browse the repository at this point in the history
…e total size in selective sync dialog.

Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed May 16, 2022
1 parent 71439f2 commit 101a92f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/gui/selectivesyncdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ void SelectiveSyncWidget::refreshFolders()
job->setProperties(props);
connect(job, &LsColJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateDirectories);
connect(job, &LsColJob::directoryListingSubfolders,
this, &SelectiveSyncWidget::slotUpdateRootFolderFilesSize);
connect(job, &LsColJob::finishedWithError,
this, &SelectiveSyncWidget::slotLscolFinishedWithError);
connect(job, &LsColJob::directoryListingIterated,
Expand Down Expand Up @@ -288,6 +290,24 @@ void SelectiveSyncWidget::slotUpdateDirectories(QStringList list)
root->setExpanded(true);
}

void SelectiveSyncWidget::slotUpdateRootFolderFilesSize(const QStringList &subfolders)
{
const auto job = qobject_cast<LsColJob *>(sender());

if (!job) {
qWarning() << "slotUpdateRootFolderFilesSize must have a valid sender";
return;
}

_rootFilesSize = 0;

for (auto it = std::cbegin(job->_folderInfos); it != std::cend(job->_folderInfos); ++it) {
if (!subfolders.contains(it.key())) {
_rootFilesSize += it.value().size;
}
}
}

void SelectiveSyncWidget::slotLscolFinishedWithError(QNetworkReply *r)
{
if (r->error() == QNetworkReply::ContentNotFoundError) {
Expand Down Expand Up @@ -454,7 +474,7 @@ qint64 SelectiveSyncWidget::estimatedSize(QTreeWidgetItem *root)
// We did not load from the server so we have no idea how much we will sync from this branch
return -1;
}
return result;
return result + _rootFilesSize;
}


Expand Down
3 changes: 3 additions & 0 deletions src/gui/selectivesyncdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SelectiveSyncWidget : public QWidget

private slots:
void slotUpdateDirectories(QStringList);
void slotUpdateRootFolderFilesSize(const QStringList &subfolders);
void slotItemExpanded(QTreeWidgetItem *);
void slotItemChanged(QTreeWidgetItem *, int);
void slotLscolFinishedWithError(QNetworkReply *);
Expand All @@ -81,6 +82,8 @@ private slots:
ExcludedFiles _excludedFiles;

QStringList _encryptedPaths;

qint64 _rootFilesSize = 0;
};

/**
Expand Down

0 comments on commit 101a92f

Please sign in to comment.