fix(sync): запретил зашифрованные storage в группах и перевёл резолв storages на FindStorageUseCase

This commit is contained in:
2026-05-17 18:04:20 +03:00
parent e562e4d9e9
commit 8fd10084f7
7 changed files with 22 additions and 33 deletions

View File

@@ -15,7 +15,6 @@ import com.github.nullptroma.wallenc.usecases.ManageStorageSyncGroupsUseCase
import com.github.nullptroma.wallenc.usecases.RunStorageSyncUseCase
import com.github.nullptroma.wallenc.usecases.StorageSyncCompatibilityInput
import com.github.nullptroma.wallenc.usecases.isStorageCompatibleWithGroup
import com.github.nullptroma.wallenc.usecases.storageEncryptionSecret
import com.github.nullptroma.wallenc.vault.contract.DescribedVault
import com.github.nullptroma.wallenc.vault.contract.VaultDescriptor
import dagger.hilt.android.lifecycle.HiltViewModel
@@ -154,15 +153,12 @@ class StorageSyncViewModel @Inject constructor(
return@withGroupMutationBusy UserNotification.TextRes(R.string.sync_storage_not_in_vaults)
}
val isEncrypted = storage.metaInfo.value.encInfo != null
val secret = vaultsManager.unlockManager
.getOpenedStorageKey(storageUuid)
?.let(::storageEncryptionSecret)
val result = groupsUseCase.addStorageToGroup(
groupId = groupId,
storageUuid = storageUuid,
compatibility = StorageSyncCompatibilityInput(
isEncrypted = isEncrypted,
encryptionSecret = secret,
encryptionSecret = null,
),
)
when (result) {
@@ -173,6 +169,9 @@ class StorageSyncViewModel @Inject constructor(
AddStorageToSyncGroupResult.AlreadyInGroup -> UserNotification.TextRes(
R.string.sync_msg_storage_already_added,
)
AddStorageToSyncGroupResult.EncryptedStorageNotAllowed -> UserNotification.TextRes(
R.string.sync_msg_only_plain_storage_allowed,
)
AddStorageToSyncGroupResult.MissingEncryptionSecret -> UserNotification.TextRes(
R.string.sync_msg_storage_encryption_key_required,
)

View File

@@ -50,6 +50,7 @@
<string name="sync_msg_storage_added">Хранилище добавлено в %1$s</string>
<string name="sync_msg_storage_removed">Хранилище убрано из %1$s</string>
<string name="sync_msg_storage_already_added">Хранилище уже добавлено в группу</string>
<string name="sync_msg_only_plain_storage_allowed">В группы синхронизации можно добавлять только незашифрованные хранилища</string>
<string name="sync_msg_storage_encryption_key_required">Для зашифрованного хранилища нужно знать пароль (откройте его перед добавлением)</string>
<string name="sync_msg_storage_incompatible_encryption">Хранилище не совместимо с политикой шифрования группы</string>
<string name="sync_msg_virtual_storage_not_supported">Нельзя добавлять открытое виртуальное хранилище: синхронизация работает с исходными raw storage</string>