mirror of
https://github.com/nextcloud/android.git
synced 2025-07-23 01:02:01 +00:00
@ -9,10 +9,10 @@ package com.nextcloud.client.jobs.operation
|
||||
|
||||
import android.content.Context
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.network.ClientFactoryImpl
|
||||
import com.nextcloud.utils.extensions.getErrorMessage
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.RemoveFileOperation
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -24,16 +24,17 @@ class FileOperationHelper(
|
||||
private val context: Context,
|
||||
private val fileDataStorageManager: FileDataStorageManager
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private val TAG = FileOperationHelper::class.java.simpleName
|
||||
}
|
||||
|
||||
private val clientFactory = ClientFactoryImpl(context)
|
||||
private val client = clientFactory.create(user)
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "Deprecation")
|
||||
suspend fun removeFile(file: OCFile, onlyLocalCopy: Boolean, inBackground: Boolean): Boolean {
|
||||
suspend fun removeFile(
|
||||
file: OCFile,
|
||||
onlyLocalCopy: Boolean,
|
||||
inBackground: Boolean,
|
||||
client: OwnCloudClient
|
||||
): Boolean {
|
||||
return withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val operation = async {
|
||||
|
@ -45,6 +45,7 @@ import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@ -174,11 +175,17 @@ class ConflictsResolveActivity :
|
||||
offlineOperation ?: return
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val isSuccess = fileOperationHelper.removeFile(serverFile, false, false)
|
||||
val client = clientRepository.getOwncloudClient() ?: return@launch
|
||||
val isSuccess = fileOperationHelper.removeFile(
|
||||
serverFile,
|
||||
onlyLocalCopy = false,
|
||||
inBackground = false,
|
||||
client = client
|
||||
)
|
||||
|
||||
if (isSuccess) {
|
||||
backgroundJobManager.startOfflineOperations()
|
||||
|
||||
launch(Dispatchers.Main) {
|
||||
withContext(Dispatchers.Main) {
|
||||
offlineOperationNotificationManager.dismissNotification(offlineOperation.id)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user