Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk
2025-07-18 16:39:36 +02:00
parent d4c3934cce
commit ff38a26345
2 changed files with 17 additions and 9 deletions

View File

@ -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 {

View File

@ -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)
}
}