mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-02-18 12:41:52 +00:00
fixes in FileKeyValueRepo
This commit is contained in:
parent
269c2876f3
commit
f0987614c6
@ -31,7 +31,8 @@ class FileReadKeyValueRepo(
|
|||||||
override suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult<File> {
|
override suspend fun values(pagination: Pagination, reversed: Boolean): PaginationResult<File> {
|
||||||
val count = count()
|
val count = count()
|
||||||
val resultPagination = if (reversed) pagination.reverse(count) else pagination
|
val resultPagination = if (reversed) pagination.reverse(count) else pagination
|
||||||
val filesPaths = folder.list() ?.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive) ?: return emptyPaginationResult()
|
val filesList = folder.list()
|
||||||
|
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size)) ?: return emptyPaginationResult()
|
||||||
if (reversed) {
|
if (reversed) {
|
||||||
filesPaths.reverse()
|
filesPaths.reverse()
|
||||||
}
|
}
|
||||||
@ -44,7 +45,8 @@ class FileReadKeyValueRepo(
|
|||||||
override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult<String> {
|
override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult<String> {
|
||||||
val count = count()
|
val count = count()
|
||||||
val resultPagination = if (reversed) pagination.reverse(count) else pagination
|
val resultPagination = if (reversed) pagination.reverse(count) else pagination
|
||||||
val filesPaths = folder.list() ?.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive) ?: return emptyPaginationResult()
|
val filesList = folder.list()
|
||||||
|
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size)) ?: return emptyPaginationResult()
|
||||||
if (reversed) {
|
if (reversed) {
|
||||||
filesPaths.reverse()
|
filesPaths.reverse()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user