Вынос IStorageInfo и IVaultInfo

This commit is contained in:
Roman Pytkov
2025-01-04 03:07:28 +03:00
parent db30408278
commit 8302e9442e
14 changed files with 34 additions and 35 deletions

View File

@@ -1,6 +1,6 @@
package com.github.nullptroma.wallenc.domain.datatypes
class DataPackage<T>(
open class DataPackage<T>(
val data: T,
val isLoading: Boolean? = false,
val isError: Boolean? = false

View File

@@ -12,7 +12,8 @@ class EncryptedStorage(
source: IStorage,
key: EncryptKey,
logger: ILogger,
ioDispatcher: CoroutineDispatcher
ioDispatcher: CoroutineDispatcher,
override val isEncrypted: Boolean
) : IStorage {
override val size: StateFlow<Long?>
get() = TODO("Not yet implemented")

View File

@@ -1,14 +1,6 @@
package com.github.nullptroma.wallenc.domain.interfaces
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID
interface IStorage {
val size: StateFlow<Long?>
val numberOfFiles: StateFlow<Int?>
val uuid: UUID
val name: StateFlow<String>
val isAvailable: StateFlow<Boolean>
interface IStorage: IStorageInfo {
val accessor: IStorageAccessor
suspend fun rename(newName: String)

View File

@@ -0,0 +1,13 @@
package com.github.nullptroma.wallenc.domain.interfaces
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID
interface IStorageInfo {
val size: StateFlow<Long?>
val numberOfFiles: StateFlow<Int?>
val uuid: UUID
val isEncrypted: Boolean
val name: StateFlow<String>
val isAvailable: StateFlow<Boolean>
}

View File

@@ -1,9 +1,12 @@
package com.github.nullptroma.wallenc.domain.interfaces
import com.github.nullptroma.wallenc.domain.datatypes.EncryptKey
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID
interface IVault : IVaultInfo {
override val storages: StateFlow<List<IStorage>>
suspend fun createStorage(): IStorage
suspend fun createStorage(key: EncryptKey): IStorage
suspend fun createStorage(key: EncryptKey, uuid: UUID): IStorage

View File

@@ -4,10 +4,10 @@ import com.github.nullptroma.wallenc.domain.enums.VaultType
import kotlinx.coroutines.flow.StateFlow
import java.util.UUID
interface IVaultInfo {
sealed interface IVaultInfo {
val type: VaultType
val uuid: UUID
val storages: StateFlow<List<IStorage>>
val storages: StateFlow<List<IStorageInfo>>
val isAvailable: StateFlow<Boolean>
val totalSpace: StateFlow<Int?>
val availableSpace: StateFlow<Int?>

View File

@@ -3,12 +3,6 @@ package com.github.nullptroma.wallenc.domain.usecases
import com.github.nullptroma.wallenc.domain.interfaces.IVaultsManager
class GetAllRawStoragesUseCase(private val manager: IVaultsManager) {
// fun getStoragesFlow() = manager.remoteVaults.combine(manager.localVault) { remote, local ->
// mutableListOf<IVault>().apply {
// addAll(remote)
// add(local)
// }
// }
val localStorages
get() = manager.localVault.storages
}

View File

@@ -3,11 +3,14 @@ package com.github.nullptroma.wallenc.domain.usecases
import com.github.nullptroma.wallenc.domain.interfaces.IDirectory
import com.github.nullptroma.wallenc.domain.interfaces.IFile
import com.github.nullptroma.wallenc.domain.interfaces.IStorage
import com.github.nullptroma.wallenc.domain.interfaces.IStorageInfo
class StorageFileManagementUseCase {
private var _storage: IStorage? = null
fun setStorage(storage: IStorage) {
fun setStorage(storage: IStorageInfo) {
if(storage !is IStorage)
throw Exception("Cannot manage storage on StorageInfo")
_storage = storage
}

View File

@@ -1,7 +0,0 @@
package com.github.nullptroma.wallenc.domain.usecases
import com.github.nullptroma.wallenc.domain.interfaces.IMetaInfo
class TestUseCase (val meta: IMetaInfo, val id: Int) {
}