mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
add auto rename for e2e
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
67e59a5c18
commit
57b8ffb087
2 changed files with 6 additions and 13 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue