Skip to content

Commit

Permalink
feat: 当mount仓库和当前仓库不在一个存储实例时,让客户端直接上传 TencentBlueKing#2151
Browse files Browse the repository at this point in the history
* feat: 当mount仓库和当前仓库不在一个存储实例时,需要将文件进行拷贝 TencentBlueKing#2151

* feat: 当mount仓库和当前仓库不在一个存储实例时,直接上传 TencentBlueKing#2151

* feat: 去掉多余代码 TencentBlueKing#2151
  • Loading branch information
zacYL authored May 16, 2024
1 parent 2cb39b0 commit 0a3b68a
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.tencent.bkrepo.common.api.constant.CharPool
import com.tencent.bkrepo.common.api.constant.HttpStatus
import com.tencent.bkrepo.common.api.exception.ErrorCodeException
import com.tencent.bkrepo.common.artifact.api.ArtifactFile
import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException
import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder
import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadContext
import com.tencent.bkrepo.common.artifact.repository.context.ArtifactRemoveContext
Expand Down Expand Up @@ -68,7 +69,7 @@ class OciBlobServiceImpl(
private val repoClient: RepositoryClient,
private val nodeClient: NodeClient,
private val ociOperationService: OciOperationService,
private val permissionManager: PermissionManager
private val permissionManager: PermissionManager,
) : OciBlobService {

override fun startUploadBlob(artifactInfo: OciBlobArtifactInfo, artifactFile: ArtifactFile) {
Expand Down Expand Up @@ -142,6 +143,16 @@ class OciBlobServiceImpl(
buildSessionIdLocationForUpload(this, domain)
return
}
// 当mount仓库和当前仓库不在一个存储实例时,直接上传
val mountRepo = repoClient.getRepoDetail(mountProjectId, mountRepoName).data
?: throw RepoNotFoundException("$mountProjectId|$mountRepoName")
val currentRepo = repoClient.getRepoDetail(projectId, repoName).data
?: throw RepoNotFoundException("$projectId|$repoName")
if (mountRepo.storageCredentials?.key != currentRepo.storageCredentials?.key) {
buildSessionIdLocationForUpload(this, domain)
return
}

// 用于新版本 blobs 路径区分
val metadata: MutableList<MetadataModel> = mutableListOf(
MetadataModel(key = BLOB_PATH_VERSION_KEY, value = BLOB_PATH_VERSION_VALUE, system = true)
Expand All @@ -159,7 +170,7 @@ class OciBlobServiceImpl(
val blobLocation = OciLocationUtils.blobLocation(ociDigest, this)
val responseProperty = ResponseProperty(
location = blobLocation,
status = HttpStatus.CREATED
status = HttpStatus.CREATED
)
OciResponseUtils.buildUploadResponse(
domain = domain,
Expand All @@ -174,7 +185,7 @@ class OciBlobServiceImpl(
val responseProperty = ResponseProperty(
uuid = uuidCreated,
location = OciLocationUtils.blobUUIDLocation(uuidCreated, artifactInfo),
status = HttpStatus.ACCEPTED,
status = HttpStatus.ACCEPTED,
contentLength = 0
)
OciResponseUtils.buildUploadResponse(
Expand Down

0 comments on commit 0a3b68a

Please sign in to comment.