diff --git a/data/src/main/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProvider.kt b/data/src/main/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProvider.kt index e7c214e2..5699a95b 100644 --- a/data/src/main/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProvider.kt +++ b/data/src/main/java/org/cryptomator/data/cloud/crypto/MasterkeyCryptoCloudProvider.kt @@ -19,6 +19,7 @@ import org.cryptomator.domain.Vault import org.cryptomator.domain.exception.BackendException import org.cryptomator.domain.exception.CancellationException import org.cryptomator.domain.exception.FatalBackendException +import org.cryptomator.domain.exception.vaultconfig.MissingVaultConfigFileException import org.cryptomator.domain.exception.vaultconfig.UnsupportedMasterkeyLocationException import org.cryptomator.domain.repository.CloudContentRepository import org.cryptomator.domain.usecases.ProgressAware @@ -204,10 +205,16 @@ class MasterkeyCryptoCloudProvider( } private fun assertLegacyVaultVersionIsSupported(version: Int) { - if (version < CryptoConstants.MIN_VAULT_VERSION) { - throw UnsupportedVaultFormatException(version, CryptoConstants.MIN_VAULT_VERSION) - } else if (version > CryptoConstants.MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG) { - throw UnsupportedVaultFormatException(version, CryptoConstants.MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG) + when { + version < CryptoConstants.MIN_VAULT_VERSION -> { + throw UnsupportedVaultFormatException(version, CryptoConstants.MIN_VAULT_VERSION) + } + version == CryptoConstants.DEFAULT_MASTERKEY_FILE_VERSION -> { + throw MissingVaultConfigFileException() + } + version > CryptoConstants.MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG -> { + throw UnsupportedVaultFormatException(version, CryptoConstants.MAX_VAULT_VERSION_WITHOUT_VAULT_CONFIG) + } } } diff --git a/domain/src/main/java/org/cryptomator/domain/exception/vaultconfig/MissingVaultConfigFileException.java b/domain/src/main/java/org/cryptomator/domain/exception/vaultconfig/MissingVaultConfigFileException.java new file mode 100644 index 00000000..0c0c6833 --- /dev/null +++ b/domain/src/main/java/org/cryptomator/domain/exception/vaultconfig/MissingVaultConfigFileException.java @@ -0,0 +1,6 @@ +package org.cryptomator.domain.exception.vaultconfig; + +import org.cryptomator.domain.exception.BackendException; + +public class MissingVaultConfigFileException extends BackendException { +} diff --git a/presentation/src/main/java/org/cryptomator/presentation/exception/ExceptionHandlers.kt b/presentation/src/main/java/org/cryptomator/presentation/exception/ExceptionHandlers.kt index 024d3bbb..abf0f223 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/exception/ExceptionHandlers.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/exception/ExceptionHandlers.kt @@ -19,6 +19,7 @@ import org.cryptomator.domain.exception.license.NoLicenseAvailableException import org.cryptomator.domain.exception.update.GeneralUpdateErrorException import org.cryptomator.domain.exception.update.HashMismatchUpdateCheckException import org.cryptomator.domain.exception.update.SSLHandshakePreAndroid5UpdateCheckException +import org.cryptomator.domain.exception.vaultconfig.MissingVaultConfigFileException import org.cryptomator.domain.exception.vaultconfig.UnsupportedMasterkeyLocationException import org.cryptomator.domain.exception.vaultconfig.VaultConfigLoadException import org.cryptomator.domain.exception.vaultconfig.VaultKeyInvalidException @@ -41,7 +42,6 @@ class ExceptionHandlers @Inject constructor(private val context: Context, defaul staticHandler(NetworkConnectionException::class.java, R.string.error_no_network_connection) staticHandler(InvalidPassphraseException::class.java, R.string.error_invalid_passphrase) staticHandler(CloudNodeAlreadyExistsException::class.java, R.string.error_file_or_folder_exists) - staticHandler(UnsupportedVaultFormatException::class.java, R.string.error_vault_version_not_supported) staticHandler(VaultAlreadyExistException::class.java, R.string.error_vault_already_exists) staticHandler(ActivityNotFoundException::class.java, R.string.error_activity_not_found) staticHandler(CloudAlreadyExistsException::class.java, R.string.error_cloud_already_exists) @@ -54,6 +54,13 @@ class ExceptionHandlers @Inject constructor(private val context: Context, defaul staticHandler(HashMismatchUpdateCheckException::class.java, R.string.error_hash_mismatch_update) staticHandler(GeneralUpdateErrorException::class.java, R.string.error_general_update) staticHandler(SSLHandshakePreAndroid5UpdateCheckException::class.java, R.string.error_general_update) + staticHandler(UnsupportedVaultFormatException::class.java, R.string.error_vault_version_not_supported) + staticHandler( + MissingVaultConfigFileException::class.java, String.format( + ResourceHelper.getString(R.string.error_vault_config_file_missing_due_to_format_999), + ResourceHelper.getString(R.string.vault_cryptomator) + ) + ) staticHandler( VaultVersionMismatchException::class.java, String.format( ResourceHelper.getString(R.string.error_vault_version_mismatch), diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 19c2638e..febc50ca 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -18,6 +18,7 @@ Wrong password A file or folder already exists. Unsupported vault. This vault has been created with another version of Cryptomator. + %1$s file is missing in your vault folder. Make sure that this file exists in your vault folder in the cloud. Vault already exists. File does not exist. Vault has been locked.