Вынос IStorageInfo и IVaultInfo
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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?>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user