Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
}
}
Expand Down
Loading