@@ -10,6 +10,7 @@ package com.nextcloud.client.jobs.operation
1010import android.content.Context
1111import com.nextcloud.client.account.User
1212import com.nextcloud.utils.extensions.getErrorMessage
13+ import com.nextcloud.utils.extensions.toFile
1314import com.owncloud.android.datamodel.FileDataStorageManager
1415import com.owncloud.android.datamodel.OCFile
1516import com.owncloud.android.db.OCUpload
@@ -24,7 +25,6 @@ import com.owncloud.android.utils.MimeTypeUtil
2425import kotlinx.coroutines.Dispatchers
2526import kotlinx.coroutines.async
2627import kotlinx.coroutines.withContext
27- import java.io.File
2828
2929class FileOperationHelper (private val user : User , private val context : Context ) {
3030 companion object {
@@ -45,26 +45,18 @@ class FileOperationHelper(private val user: User, private val context: Context)
4545 fun isSameRemoteFileAlreadyPresent (upload : OCUpload , storageManager : FileDataStorageManager ): Boolean {
4646 val (lc, uc) = FileUtil .getRemotePathVariants(upload.remotePath)
4747
48- val remoteFile = storageManager.getFileByDecryptedRemotePath(lc)
49- ? : storageManager.getFileByDecryptedRemotePath(uc)
48+ val remoteFile = storageManager.run {
49+ getFileByDecryptedRemotePath(lc) ? : getFileByDecryptedRemotePath(uc)
50+ }
5051
51- if (remoteFile != null && isSameFileOnRemote( remoteFile, upload) ) {
52+ if (upload.toFile()?.length() == remoteFile?.fileLength ) {
5253 Log_OC .w(TAG , " Same file already exists due to lowercase/uppercase extension" )
5354 return true
5455 }
5556
5657 return false
5758 }
5859
59- fun isSameFileOnRemote (remoteFile : OCFile , upload : OCUpload ): Boolean {
60- val localFile = File (upload.localPath)
61- if (! localFile.exists()) {
62- return false
63- }
64- val localSize: Long = localFile.length()
65- return remoteFile.fileLength == localSize
66- }
67-
6860 @Suppress(" DEPRECATION" )
6961 fun getRemoteFile (remotePath : String , client : OwnCloudClient ): RemoteFile ? {
7062 val mimeType = MimeTypeUtil .getMimeTypeFromPath(remotePath)
0 commit comments