Skip to content

Commit

Permalink
fix: Lfs仓库缓存文件Http响应未关闭 TencentBlueKing#1353 (TencentBlueKing#1424)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan authored Nov 17, 2023
1 parent c34518c commit b570066
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ class LfsRemoteRepository : RemoteRepository() {
val actionDetail = lfsObject.actions!![DOWNLOAD_OPERATION]!!
with(actionDetail) {
val request = Request.Builder().url(href).headers(header.toHeaders()).get().build()
val response = httpClient.newCall(request).execute()
return if (checkResponse(response)) {
onDownloadResponse(context, response, lfsObject.size)
} else null
httpClient.newCall(request).execute().use {
return if (checkResponse(it)) {
onDownloadResponse(context, it, lfsObject.size)
} else null
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ package com.tencent.bkrepo.lfs.security

import com.tencent.bkrepo.common.api.constant.BASIC_AUTH_PREFIX
import com.tencent.bkrepo.common.api.constant.HttpHeaders
import com.tencent.bkrepo.common.api.constant.StringPool
import com.tencent.bkrepo.common.api.util.BasicAuthUtils
import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory
import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder
Expand Down Expand Up @@ -70,11 +69,6 @@ class RemoteAuthHandler : HttpAuthHandler {

override fun onAuthenticate(request: HttpServletRequest, authCredentials: HttpAuthCredentials): String {
require(authCredentials is BasicAuthCredentials)
val passwordLength = authCredentials.password.length
val maskPassword = authCredentials.password.replaceRange(
IntRange(passwordLength / 2, passwordLength - 1),
StringPool.POUND.repeat(5)
)
return "${authCredentials.username}:$maskPassword"
return authCredentials.username
}
}

0 comments on commit b570066

Please sign in to comment.