mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Handle case with quota 0
This commit is contained in:
parent
a21614fd5a
commit
f3566d667e
@ -160,8 +160,10 @@ public class GetRemoteUserQuotaOperation extends RemoteOperation {
|
|||||||
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getWebdavUri().getPath());
|
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getWebdavUri().getPath());
|
||||||
|
|
||||||
// If there's a special case, available bytes will contain a negative code
|
// If there's a special case, available bytes will contain a negative code
|
||||||
if (we.quotaAvailableBytes().compareTo(new BigDecimal(0)) == -1) {
|
// -1, PENDING: Not computed yet, e.g. external storage mounted but folder sizes need scanning
|
||||||
|
// -2, UNKNOWN: Storage not accessible, e.g. external storage with no API to ask for the free space
|
||||||
|
// -3, UNLIMITED: Quota using all the storage
|
||||||
|
if (we.quotaAvailableBytes().compareTo(new BigDecimal(1)) == -1) {
|
||||||
return new Quota(
|
return new Quota(
|
||||||
we.quotaAvailableBytes().longValue(),
|
we.quotaAvailableBytes().longValue(),
|
||||||
we.quotaUsedBytes().longValue(),
|
we.quotaUsedBytes().longValue(),
|
||||||
@ -171,18 +173,18 @@ public class GetRemoteUserQuotaOperation extends RemoteOperation {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
BigDecimal totalQuota = we.quotaAvailableBytes().add(we.quotaUsedBytes());
|
BigDecimal totalQuota = we.quotaAvailableBytes().add(we.quotaUsedBytes());
|
||||||
|
|
||||||
BigDecimal relativeQuota = we.quotaUsedBytes()
|
BigDecimal relativeQuota = we.quotaUsedBytes()
|
||||||
.multiply(new BigDecimal(100))
|
.multiply(new BigDecimal(100))
|
||||||
.divide(totalQuota);
|
.divide(totalQuota);
|
||||||
|
|
||||||
return new Quota(
|
return new Quota(
|
||||||
we.quotaAvailableBytes().longValue(),
|
we.quotaAvailableBytes().longValue(),
|
||||||
we.quotaUsedBytes().longValue(),
|
we.quotaUsedBytes().longValue(),
|
||||||
totalQuota.longValue(),
|
totalQuota.longValue(),
|
||||||
relativeQuota.doubleValue()
|
relativeQuota.doubleValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user