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