Skip to content

Commit

Permalink
Add specific message for existing folders exceeding warning limit in …
Browse files Browse the repository at this point in the history
…accountsettings

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Jul 4, 2023
1 parent 0c49c1d commit 81721c5
Showing 1 changed file with 38 additions and 14 deletions.
52 changes: 38 additions & 14 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


#include "accountsettings.h"
#include "common/syncjournaldb.h"
#include "common/syncjournalfilerecord.h"
#include "qmessagebox.h"
#include "ui_accountsettings.h"
Expand Down Expand Up @@ -1478,10 +1479,15 @@ void AccountSettings::folderTerminateSyncAndUpdateBlackList(const QStringList &b
void AccountSettings::refreshSelectiveSyncStatus()
{
QString unsyncedMsg;
QString becameBigMsg;

auto cnt = 0;
const auto folders = FolderMan::instance()->map().values();

static const auto folderLinkString = [](const QString &slashlessFolderPath, const QString &folderName) {
return QStringLiteral("<a href=\"%1?folder=%2\">%1</a>").arg(slashlessFolderPath, folderName);
};

_ui->bigFolderUi->setVisible(false);

for (const auto folder : folders) {
Expand All @@ -1501,30 +1507,48 @@ void AccountSettings::refreshSelectiveSyncStatus()
unsyncedMsg += QStringLiteral(", ");
}

const auto folderTrailingSlash = it.endsWith('/') ? it : it + QChar('/');
const auto folderWithoutTrailingSlash = it.endsWith('/') ? it.left(it.length() - 1) : it;

const auto escapedFolderString = Utility::escape(folderWithoutTrailingSlash);
const auto escapedFolderName = Utility::escape(folder->alias());
const auto folderIdx = _model->indexForPath(folder, folderWithoutTrailingSlash);
if (folderIdx.isValid()) {
const auto escapedFolderString = Utility::escape(folderWithoutTrailingSlash);
const auto escapedFolderName = Utility::escape(folder->alias());
unsyncedMsg += QStringLiteral("<a href=\"%1?folder=%2\">%1</a>").arg(escapedFolderString, escapedFolderName);

// If we do not know the index yet then do not provide a link string
const auto folderDisplayString = folderIdx.isValid() ? folderLinkString(escapedFolderString, escapedFolderName) : folderWithoutTrailingSlash;

// The new big folder procedure automatically places these new big folders in the blacklist.
// This is not the case for existing folders discovered to have gone beyond the limit.
// We need to check if the folder is in the blacklist or not and tweak the message accordingly.
if (SyncJournalDb::findPathInSelectiveSyncList(blacklist, folderTrailingSlash)) {
unsyncedMsg += folderDisplayString;
} else {
unsyncedMsg += folderWithoutTrailingSlash; // no link because we do not know the index yet.
becameBigMsg += folderDisplayString;
}
}
}

ConfigFile cfg;
QString infoString;

if (!unsyncedMsg.isEmpty()) {
ConfigFile cfg;
const auto info = !cfg.confirmExternalStorage() ?
tr("There are folders that were not synchronized because they are too big: ") :
!cfg.newBigFolderSizeLimit().first ?
tr("There are folders that were not synchronized because they are external storages: ") :
tr("There are folders that were not synchronized because they are too big or external storages: ");
infoString += !cfg.confirmExternalStorage() ? tr("There are folders that were not synchronized because they are too big: ")
: !cfg.newBigFolderSizeLimit().first ? tr("There are folders that were not synchronized because they are external storages: ")
: tr("There are folders that were not synchronized because they are too big or external storages: ");

_ui->selectiveSyncNotification->setText(info + unsyncedMsg);
_ui->bigFolderUi->setVisible(true);
infoString += unsyncedMsg;
}

if (!becameBigMsg.isEmpty()) {
if (!infoString.isEmpty()) {
infoString += QStringLiteral("\n");
}

const auto folderSizeLimitString = QString::number(cfg.newBigFolderSizeLimit().second);
infoString += tr("There are folders that have grown in size beyond %1MB: %2").arg(folderSizeLimitString, becameBigMsg);
}

_ui->selectiveSyncNotification->setText(infoString + unsyncedMsg + becameBigMsg);
_ui->bigFolderUi->setVisible(!infoString.isEmpty());
}

bool AccountSettings::event(QEvent *e)
Expand Down

0 comments on commit 81721c5

Please sign in to comment.