File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
opencloudApp/src/main/java/eu/opencloud/android/workers Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -327,6 +327,11 @@ class UploadFileFromFileSystemWorker(
327327 }
328328
329329 private fun updateProgressFromTus (offset : Long , totalSize : Long ) {
330+ if (this .isStopped) {
331+ Timber .w(" Cancelling TUS upload. The worker is stopped by user or system" )
332+ tusUploadHelper.cancel()
333+ }
334+
330335 if (totalSize <= 0 ) return
331336 val percent: Int = (100.0 * offset.toDouble() / totalSize.toDouble()).toInt()
332337 if (percent == lastPercent) return
@@ -446,6 +451,14 @@ class UploadFileFromFileSystemWorker(
446451 totalToTransfer : Long ,
447452 filePath : String
448453 ) {
454+ if (this .isStopped) {
455+ Timber .w(" Cancelling upload operation. The worker is stopped by user or system" )
456+ if (::uploadFileOperation.isInitialized) {
457+ uploadFileOperation.cancel()
458+ uploadFileOperation.removeDataTransferProgressListener(this )
459+ }
460+ }
461+
449462 val percent: Int = (100.0 * totalTransferredSoFar.toDouble() / totalToTransfer.toDouble()).toInt()
450463 if (percent == lastPercent) return
451464
You can’t perform that action at this time.
0 commit comments