add auto rename for e2e

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-09-19 17:32:27 +02:00 committed by Alper Öztürk
parent 67e59a5c18
commit 57b8ffb087
2 changed files with 6 additions and 13 deletions

View file

@ -13,8 +13,6 @@ import com.nextcloud.utils.extensions.forbiddenFilenameExtension
import com.nextcloud.utils.extensions.shouldRemoveNonPrintableUnicodeCharacters
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.status.OCCapability
import org.apache.commons.io.FileUtils
import java.io.File
import java.util.regex.Pattern
object AutoRename {
@ -72,17 +70,6 @@ object AutoRename {
}
}
fun renameFile(file: File, capability: OCCapability): File {
if (!file.exists()) {
return file
}
val newFilename = rename(file.name, capability)
val newFile = File(file.parentFile, newFilename)
FileUtils.moveFile(file, newFile)
return newFile
}
private fun convertToUTF8(filename: String): String {
return String(filename.toByteArray(), Charsets.UTF_8)
}

View file

@ -12,6 +12,7 @@ import android.content.Context
import androidx.annotation.VisibleForTesting
import com.google.gson.reflect.TypeToken
import com.nextcloud.client.account.User
import com.nextcloud.utils.autoRename.AutoRename
import com.owncloud.android.MainApp
import com.owncloud.android.R
import com.owncloud.android.datamodel.ArbitraryDataProvider
@ -674,6 +675,11 @@ class EncryptionUtilsV2 {
// throw IllegalStateException("Metadata is corrupt!")
// }
// Auto rename if oc capability enabled for windows compatibility
decryptedFolderMetadata.metadata.files.values.forEach { file ->
file.filename = AutoRename.rename(file.filename, storageManager.getCapability(user))
}
return decryptedFolderMetadata
// handle filesDrops