package com.github.nullptroma.wallenc.usecases

import com.github.nullptroma.wallenc.domain.interfaces.IStorage
import com.github.nullptroma.wallenc.domain.interfaces.StorageSyncGroup
import com.github.nullptroma.wallenc.domain.interfaces.StorageSyncGroupEncryptionKind

/** Совместим, если у storage нет активного шифрования ([encInfo] == null). */
fun isStorageCompatibleWithGroup(
    storage: IStorage,
    group: StorageSyncGroup,
): Boolean {
    if (storage.metaInfo.value.encInfo != null) {
        return false
    }
    return when (group.encryptionKind) {
        StorageSyncGroupEncryptionKind.UNSET -> true
        StorageSyncGroupEncryptionKind.NONE -> true
        StorageSyncGroupEncryptionKind.PASSWORD -> false
    }
}
