Локальное хранилище теперь читает файлы и создаёт .wallenc-meta

This commit is contained in:
Пытков Роман
2024-12-21 22:45:02 +03:00
parent cf443487ee
commit 577939e953
18 changed files with 324 additions and 102 deletions

View File

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

View File

@@ -2,7 +2,9 @@ package com.github.nullptroma.wallenc.domain.datatypes
class DataPage<T>(
list: List<T>,
isLoading: Boolean? = false,
isError: Boolean? = false,
val hasNext: Boolean? = false,
val pageLength: Int,
val pageNumber: Int
) : DataPackage<List<T>>(list)
val pageIndex: Int
) : DataPackage<List<T>>(data = list, isLoading = isLoading, isError = isError)

View File

@@ -2,5 +2,5 @@ package com.github.nullptroma.wallenc.domain.models
interface IDirectory {
val metaInfo: IMetaInfo
val elementsCount: Int
val elementsCount: Int?
}

View File

@@ -4,8 +4,7 @@ import java.time.LocalDateTime
interface IMetaInfo {
val name: String
val size: Int
val size: Long
val isDeleted: Boolean
val isHidden: Boolean
val lastModified: LocalDateTime

View File

@@ -21,7 +21,7 @@ interface IStorageAccessor {
* @param path Путь к директории
* @return Поток файлов
*/
fun getFilesFlow(path: String): Flow<DataPackage<IFile>>
fun getFilesFlow(path: String): Flow<DataPackage<List<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<IDirectory>>
fun getDirsFlow(path: String): Flow<DataPackage<List<IDirectory>>>
suspend fun touchFile(path: String)
suspend fun touchDir(path: String)

View File

@@ -0,0 +1,17 @@
package com.github.nullptroma.wallenc.domain.usecases
import com.github.nullptroma.wallenc.domain.models.IFile
import com.github.nullptroma.wallenc.domain.models.IStorage
class StorageFileManagementUseCase {
private var _storage: IStorage? = null
fun setStorage(storage: IStorage) {
_storage = storage
}
suspend fun getAllFiles(): List<IFile> {
val storage = _storage ?: return listOf()
return storage.accessor.getAllFiles()
}
}