Show specific message if vault.cryptomator is missing in vault version 8

Fixes 381
This commit is contained in:
Julian Raufelder 2022-03-15 17:53:31 +01:00
parent 8f2a94e98f
commit 0fc53f9242
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
4 changed files with 26 additions and 5 deletions

View File

@ -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)
}
}
}

View File

@ -0,0 +1,6 @@
package org.cryptomator.domain.exception.vaultconfig;
import org.cryptomator.domain.exception.BackendException;
public class MissingVaultConfigFileException extends BackendException {
}

View File

@ -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),

View File

@ -18,6 +18,7 @@
<string name="error_invalid_passphrase">Wrong password</string>
<string name="error_file_or_folder_exists">A file or folder already exists.</string>
<string name="error_vault_version_not_supported">Unsupported vault. This vault has been created with another version of Cryptomator.</string>
<string name="error_vault_config_file_missing_due_to_format_999">%1$s file is missing in your vault folder. Make sure that this file exists in your vault folder in the cloud.</string>
<string name="error_vault_already_exists">Vault already exists.</string>
<string name="error_no_such_file">File does not exist.</string>
<string name="error_vault_has_been_locked">Vault has been locked.</string>