mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-20 07:13:50 +00:00
fixes in FileKeyValueRepo
This commit is contained in:
parent
f0987614c6
commit
225c06550a
@ -32,11 +32,18 @@ class FileReadKeyValueRepo(
|
|||||||
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 filesList = folder.list()
|
val filesList = folder.list()
|
||||||
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size)) ?: return emptyPaginationResult()
|
val files: Array<String> = if (resultPagination.firstIndex < count) {
|
||||||
if (reversed) {
|
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size))
|
||||||
filesPaths.reverse()
|
|
||||||
|
if (reversed) {
|
||||||
|
filesPaths.reversedArray()
|
||||||
|
} else {
|
||||||
|
filesPaths
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
emptyArray<String>()
|
||||||
}
|
}
|
||||||
return filesPaths.map { File(folder, it) }.createPaginationResult(
|
return files.map { File(folder, it) }.createPaginationResult(
|
||||||
resultPagination,
|
resultPagination,
|
||||||
count
|
count
|
||||||
)
|
)
|
||||||
@ -46,11 +53,20 @@ class FileReadKeyValueRepo(
|
|||||||
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 filesList = folder.list()
|
val filesList = folder.list()
|
||||||
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size)) ?: return emptyPaginationResult()
|
|
||||||
if (reversed) {
|
val files: Array<String> = if (resultPagination.firstIndex < count) {
|
||||||
filesPaths.reverse()
|
val filesPaths = filesList.copyOfRange(resultPagination.firstIndex, resultPagination.lastIndexExclusive.coerceAtMost(filesList.size))
|
||||||
|
|
||||||
|
if (reversed) {
|
||||||
|
filesPaths.reversedArray()
|
||||||
|
} else {
|
||||||
|
filesPaths
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
emptyArray<String>()
|
||||||
}
|
}
|
||||||
return filesPaths.toList().createPaginationResult(
|
|
||||||
|
return files.toList().createPaginationResult(
|
||||||
resultPagination,
|
resultPagination,
|
||||||
count
|
count
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user