Локальное хранилище теперь читает файлы и создаёт .wallenc-meta
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -2,5 +2,5 @@ package com.github.nullptroma.wallenc.domain.models
|
||||
|
||||
interface IDirectory {
|
||||
val metaInfo: IMetaInfo
|
||||
val elementsCount: Int
|
||||
val elementsCount: Int?
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user