From 1ce1bbba42496b647a0134f7791015a31f69506b Mon Sep 17 00:00:00 2001 From: kunlongli Date: Mon, 9 Dec 2024 11:26:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0ddc=20blob=E5=BC=95=E7=94=A8=E6=95=B0=20#2825?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/bkrepo/ddc/service/BlobService.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/service/BlobService.kt b/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/service/BlobService.kt index 5ff2de0a0c..d69d313128 100644 --- a/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/service/BlobService.kt +++ b/src/backend/ddc/biz-ddc/src/main/kotlin/com/tencent/bkrepo/ddc/service/BlobService.kt @@ -111,14 +111,18 @@ class BlobService( fun addRefToBlobs(ref: Reference, blobIds: Set) { with(ref) { val addedBlobIds = blobRefRepository.addRefToBlob(projectId, repoName, bucket, key.toString(), blobIds) - blobRepository.incRefCount(projectId, repoName, addedBlobIds) + if (addedBlobIds.isNotEmpty()) { + blobRepository.incRefCount(projectId, repoName, addedBlobIds) + } } } fun removeRefFromBlobs(projectId: String, repoName: String, bucket: String, key: String) { val blobIds = HashSet() blobRefRepository.removeRefFromBlob(projectId, repoName, bucket, key).mapTo(blobIds) { it.blobId } - blobRepository.incRefCount(projectId, repoName, blobIds, -1L) + if (blobIds.isNotEmpty()) { + blobRepository.incRefCount(projectId, repoName, blobIds, -1L) + } // 兼容旧逻辑,所有blob的references字段为空后可以移除该逻辑 blobRepository.removeRefFromBlob(projectId, repoName, bucket, key) }