Skip to content

Commit d1c80d5

Browse files
Merge pull request #15221 from nextcloud/showQuotaErrorMessage
Show quota error message
2 parents 121b60a + 288e961 commit d1c80d5

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ class FileUploadWorker(
262262
val entity = uploadsStorageManager.uploadDao.getUploadById(upload.uploadId, accountName)
263263
uploadsStorageManager.updateStatus(entity, result.isSuccess)
264264
currentUploadFileOperation = null
265+
266+
if (result.code == ResultCode.QUOTA_EXCEEDED) {
267+
Log_OC.w(TAG, "Quota exceeded, stopping uploads")
268+
notificationManager.showQuotaExceedNotification(operation, result.code)
269+
break
270+
}
271+
265272
sendUploadFinishEvent(totalUploadSize, currentUploadIndex, operation, result)
266273
}
267274

app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.nextcloud.utils.extensions.isFileSpecificError
1414
import com.nextcloud.utils.numberFormatter.NumberFormatter
1515
import com.owncloud.android.R
1616
import com.owncloud.android.lib.common.operations.RemoteOperationResult
17+
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
1718
import com.owncloud.android.operations.UploadFileOperation
1819
import com.owncloud.android.ui.notifications.NotificationUtils
1920
import com.owncloud.android.utils.theme.ViewThemeUtils
@@ -152,7 +153,7 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
152153
private fun showNewNotification(operation: UploadFileOperation) {
153154
notificationManager.notify(
154155
NotificationUtils.createUploadNotificationTag(operation.file),
155-
FileUploadWorker.NOTIFICATION_ERROR_ID,
156+
operation.file.hashCode(),
156157
notificationBuilder.build()
157158
)
158159
}
@@ -174,6 +175,17 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
174175
)
175176
}
176177

178+
fun showQuotaExceedNotification(operation: UploadFileOperation, resultCode: ResultCode) {
179+
notifyForFailedResult(
180+
operation,
181+
resultCode,
182+
null,
183+
null,
184+
null,
185+
context.getString(R.string.upload_quota_exceeded)
186+
)
187+
}
188+
177189
fun showConnectionErrorNotification() {
178190
notificationManager.cancel(getId())
179191

0 commit comments

Comments
 (0)