mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Quota: Change quota path if single folder #4460
Since the quota is a per-folder value, this will make the displayed data more useful when a single sync folder is configured. Of course each subfolder could have a different quota again.
This commit is contained in:
parent
0febe9b0df
commit
ff4cdc3161
@ -15,6 +15,7 @@
|
||||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "networkjobs.h"
|
||||
#include "folderman.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
|
||||
#include <QTimer>
|
||||
@ -79,6 +80,24 @@ bool QuotaInfo::canGetQuota() const
|
||||
&& account->credentials()->ready();
|
||||
}
|
||||
|
||||
QString QuotaInfo::quotaBaseFolder() const
|
||||
{
|
||||
// If there's exactly one folder, use its remote path.
|
||||
// Otherwise use /
|
||||
bool foundOne = false;
|
||||
QString path = "/";
|
||||
for (const auto & folder : FolderMan::instance()->map()) {
|
||||
if (folder->accountState() == _accountState) {
|
||||
if (foundOne)
|
||||
return "/";
|
||||
foundOne = true;
|
||||
path = folder->remotePath();
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void QuotaInfo::slotCheckQuota()
|
||||
{
|
||||
if (! canGetQuota()) {
|
||||
@ -91,7 +110,7 @@ void QuotaInfo::slotCheckQuota()
|
||||
}
|
||||
|
||||
AccountPtr account = _accountState->account();
|
||||
_job = new PropfindJob(account, "/", this);
|
||||
_job = new PropfindJob(account, quotaBaseFolder(), this);
|
||||
_job->setProperties(QList<QByteArray>() << "quota-available-bytes" << "quota-used-bytes");
|
||||
connect(_job, SIGNAL(result(QVariantMap)), SLOT(slotUpdateLastQuota(QVariantMap)));
|
||||
connect(_job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotRequestFailed()));
|
||||
|
||||
@ -71,6 +71,9 @@ Q_SIGNALS:
|
||||
private:
|
||||
bool canGetQuota() const;
|
||||
|
||||
/// Returns the folder that quota shall be retrieved for
|
||||
QString quotaBaseFolder() const;
|
||||
|
||||
QPointer<AccountState> _accountState;
|
||||
qint64 _lastQuotaTotalBytes;
|
||||
qint64 _lastQuotaUsedBytes;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user