refactor(vault): extract BaseStorage and align storage interfaces
Consolidate duplicated meta-info and clear logic into BaseStorage. Promote system file accessors and DataPage-based flows into IStorageAccessor. Use Long for vault disk space to support cloud byte counts. Combine local and remote storages in VaultsManager so UnlockManager sees all backends. Yandex Disk REST integration (phase B) is deferred to a follow-up change. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package com.github.nullptroma.wallenc.domain.interfaces
|
||||
|
||||
import com.github.nullptroma.wallenc.domain.datatypes.DataPackage
|
||||
import com.github.nullptroma.wallenc.domain.datatypes.DataPage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
@@ -11,8 +11,8 @@ interface IStorageAccessor {
|
||||
val size: StateFlow<Long?>
|
||||
val numberOfFiles: StateFlow<Int?>
|
||||
val isAvailable: StateFlow<Boolean>
|
||||
val filesUpdates: SharedFlow<DataPackage<List<IFile>>>
|
||||
val dirsUpdates: SharedFlow<DataPackage<List<IDirectory>>>
|
||||
val filesUpdates: SharedFlow<DataPage<IFile>>
|
||||
val dirsUpdates: SharedFlow<DataPage<IDirectory>>
|
||||
|
||||
suspend fun getAllFiles(): List<IFile>
|
||||
suspend fun getFiles(path: String): List<IFile>
|
||||
@@ -21,7 +21,7 @@ interface IStorageAccessor {
|
||||
* @param path Путь к директории
|
||||
* @return Поток файлов
|
||||
*/
|
||||
fun getFilesFlow(path: String): Flow<DataPackage<List<IFile>>>
|
||||
fun getFilesFlow(path: String): Flow<DataPage<IFile>>
|
||||
|
||||
suspend fun getAllDirs(): List<IDirectory>
|
||||
suspend fun getDirs(path: String): List<IDirectory>
|
||||
@@ -30,7 +30,7 @@ interface IStorageAccessor {
|
||||
* @param path Путь к директории
|
||||
* @return Поток директорий
|
||||
*/
|
||||
fun getDirsFlow(path: String): Flow<DataPackage<List<IDirectory>>>
|
||||
fun getDirsFlow(path: String): Flow<DataPage<IDirectory>>
|
||||
suspend fun getFileInfo(path: String): IFile
|
||||
suspend fun getDirInfo(path: String): IDirectory
|
||||
suspend fun setHidden(path: String, hidden: Boolean)
|
||||
@@ -40,4 +40,12 @@ interface IStorageAccessor {
|
||||
suspend fun openWrite(path: String): OutputStream
|
||||
suspend fun openRead(path: String): InputStream
|
||||
suspend fun moveToTrash(path: String)
|
||||
|
||||
/**
|
||||
* Системный sidecar-файл для логических нужд хранилища (мета, ключи и т.п.).
|
||||
* Конкретный accessor решает, где он физически живёт, но он не должен
|
||||
* попадать в выдачу [getFiles]/[getDirs]/[size]/[numberOfFiles].
|
||||
*/
|
||||
suspend fun openReadSystemFile(name: String): InputStream
|
||||
suspend fun openWriteSystemFile(name: String): OutputStream
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import kotlinx.coroutines.flow.StateFlow
|
||||
interface IVault : IVaultInfo {
|
||||
val storages: StateFlow<List<IStorage>>
|
||||
val isAvailable: StateFlow<Boolean>
|
||||
val totalSpace: StateFlow<Int?>
|
||||
val availableSpace: StateFlow<Int?>
|
||||
val totalSpace: StateFlow<Long?>
|
||||
val availableSpace: StateFlow<Long?>
|
||||
|
||||
suspend fun createStorage(): IStorage
|
||||
suspend fun createStorage(enc: StorageEncryptionInfo): IStorage
|
||||
|
||||
Reference in New Issue
Block a user