Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit d6ea580

Browse files
committed
Take care when quota available and used are 0
1 parent 59229aa commit d6ea580

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
9292
quotaUsed = property.quotaUsedBytes
9393
}
9494
}
95-
95+
Timber.d("Quota used: $quotaUsed, QuotaAvailable: $quotaAvailable")
9696
// If there's a special case, quota available will contain a negative code
9797
// -1, PENDING: Not computed yet, e.g. external storage mounted but folder sizes need scanning
9898
// -2, UNKNOWN: Storage not accessible, e.g. external storage with no API to ask for the free space
@@ -106,8 +106,11 @@ class GetRemoteUserQuotaOperation : RemoteOperation<RemoteQuota>() {
106106
)
107107
} else {
108108
val totalQuota = quotaAvailable + quotaUsed
109-
val relativeQuota = (quotaUsed * 100).toDouble() / totalQuota
110-
val roundedRelativeQuota = (relativeQuota * 100).roundToLong() / 100.0
109+
val roundedRelativeQuota = if (totalQuota > 0) {
110+
val relativeQuota = (quotaUsed * 100).toDouble() / totalQuota
111+
(relativeQuota * 100).roundToLong() / 100.0
112+
} else 0.0
113+
111114
RemoteQuota(quotaAvailable, quotaUsed, totalQuota, roundedRelativeQuota)
112115
}
113116
}

0 commit comments

Comments
 (0)