From: Olivier Goffart Date: Thu, 29 Oct 2015 13:33:29 +0000 (+0100) Subject: Quota: handle special negative value for the quota #3940 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1474 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a127debc54c001e3d47f4d0e4b54bce01ad797f7;p=nextcloud-desktop.git Quota: handle special negative value for the quota #3940 Don't show a progress bar if there is an unkown or unlimited total --- diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 962cddda7..fa3d7ae88 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -455,7 +455,15 @@ void AccountSettings::slotUpdateQuota(qint64 total, qint64 used) ui->quotaProgressBar->setToolTip(toolTip); } else { ui->quotaProgressBar->setVisible(false); - ui->quotaInfoLabel->setText(tr("Currently there is no storage usage information available.")); + ui->quotaInfoLabel->setToolTip(QString()); + + /* -1 means not computed; -2 means unknown; -3 means unlimited (#3940)*/ + if (total == 0 || total == -1) { + ui->quotaInfoLabel->setText(tr("Currently there is no storage usage information available.")); + } else { + QString usedStr = Utility::octetsToString(used); + ui->quotaInfoLabel->setText(tr("%1 in use").arg(usedStr)); + } } } diff --git a/src/gui/quotainfo.cpp b/src/gui/quotainfo.cpp index 49c188bdd..02d5dfdc4 100644 --- a/src/gui/quotainfo.cpp +++ b/src/gui/quotainfo.cpp @@ -102,9 +102,10 @@ void QuotaInfo::slotUpdateLastQuota(const QVariantMap &result) { // The server can return fractional bytes (#1374) // 1374532061.2 - quint64 avail = result["quota-available-bytes"].toDouble(); + qint64 avail = result["quota-available-bytes"].toDouble(); _lastQuotaUsedBytes = result["quota-used-bytes"].toDouble(); - _lastQuotaTotalBytes = _lastQuotaUsedBytes + avail; + // negative value of the available quota have special meaning (#3940) + _lastQuotaTotalBytes = avail >= 0 ? _lastQuotaUsedBytes + avail : avail; emit quotaUpdated(_lastQuotaTotalBytes, _lastQuotaUsedBytes); _jobRestartTimer.start(defaultIntervalT); _lastQuotaRecieved = QDateTime::currentDateTime();