diff --git a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/service/ClientService.kt b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/service/ClientService.kt index fa84456471..7ce4b06dff 100644 --- a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/service/ClientService.kt +++ b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/service/ClientService.kt @@ -41,7 +41,6 @@ import com.tencent.bkrepo.fs.server.request.ClientCreateRequest import com.tencent.bkrepo.fs.server.utils.ReactiveSecurityUtils import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query -import org.springframework.data.mongodb.core.query.Update import org.springframework.data.mongodb.core.query.isEqualTo import java.time.LocalDateTime @@ -85,12 +84,11 @@ class ClientService( .and(TClient::repoName.name).isEqualTo(repoName) .and(TClient::id.name).isEqualTo(clientId) ) - val update = Update().set(TClient::heartbeatTime.name, LocalDateTime.now()) - .set(TClient::online.name, true) - val result = clientRepository.upsert(query, update) - if (result.matchedCount == 0L) { - throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, clientId) - } + val client = clientRepository.findOne(query) + ?: throw ErrorCodeException(CommonMessageCode.RESOURCE_NOT_FOUND, clientId) + client.heartbeatTime = LocalDateTime.now() + client.online = true + clientRepository.save(client) } private suspend fun insertClient(request: ClientCreateRequest): TClient {