race condition fix

This commit is contained in:
2026-06-13 14:40:31 +03:00
parent 9c3548c6f2
commit 804203c698
98 changed files with 96 additions and 289 deletions
@@ -1,20 +1,21 @@
package commands
import collection.CollectionManager
import database.Repository
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import models.HumanBeing
import network.Response
@Serializable
class ShowCommand(@Contextual private val manager: CollectionManager) : Command {
class ShowCommand(@Contextual private val repository: Repository) : Command {
override val name = "show"
override val description = "вывести все элементы коллекции"
override val type = CommandType.SIMPLE
override val args = listOf(CommandArgType.NONE)
override fun execute(args: List<String>, humanBeing: HumanBeing?, userId: String): Response {
if (manager.isEmpty()) return Response(true, "Коллекция пуста.")
return Response(true, manager.getAll().joinToString("\n") { it.toString() })
val all = repository.getAll()
if (all.isEmpty()) return Response(true, "Коллекция пуста.")
return Response(true, all.joinToString("\n") { it.toString() })
}
}