diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserNodeController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserNodeController.kt index 42c67689d5..b6c3f5c154 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserNodeController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserNodeController.kt @@ -190,7 +190,10 @@ class UserNodeController( @RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) date: LocalDateTime ): Response { return ResponseBuilder.success( - nodeService.deleteBeforeDate(artifactInfo.projectId, artifactInfo.repoName, date, userId) + nodeService.deleteBeforeDate( + artifactInfo.projectId, artifactInfo.repoName, + date, userId, artifactInfo.getArtifactFullPath() + ) ) } diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/NodeDeleteOperation.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/NodeDeleteOperation.kt index c3731219d6..2383d62ca7 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/NodeDeleteOperation.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/NodeDeleteOperation.kt @@ -69,5 +69,8 @@ interface NodeDeleteOperation { /** * 根据创建时间删除[date]之前的历史数据 */ - fun deleteBeforeDate(projectId: String, repoName: String, date: LocalDateTime, operator: String): NodeDeleteResult + fun deleteBeforeDate( + projectId: String, repoName: String, + date: LocalDateTime, operator: String, path: String + ): NodeDeleteResult } diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeDeleteSupport.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeDeleteSupport.kt index 176e8945b9..36a0a600aa 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeDeleteSupport.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeDeleteSupport.kt @@ -156,10 +156,11 @@ open class NodeDeleteSupport( projectId: String, repoName: String, date: LocalDateTime, - operator: String + operator: String, + path: String ): NodeDeleteResult { val option = NodeListOption(includeFolder = false, deep = true) - val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, PathUtils.ROOT, option) + val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, path, option) .and(TNode::createdDate).lt(date) val query = Query(criteria) return delete(query, operator, criteria, projectId, repoName) diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt index 1f3fb9ac84..07aee69c3c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt @@ -125,9 +125,10 @@ class NodeServiceImpl( projectId: String, repoName: String, date: LocalDateTime, - operator: String + operator: String, + path: String ): NodeDeleteResult { - return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator) + return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator, path) } @Transactional(rollbackFor = [Throwable::class]) diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeDeleteSupport.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeDeleteSupport.kt index de48a96519..f776c712ce 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeDeleteSupport.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeDeleteSupport.kt @@ -99,12 +99,13 @@ class CommitEdgeCenterNodeDeleteSupport( projectId: String, repoName: String, date: LocalDateTime, - operator: String + operator: String, + path: String ): NodeDeleteResult { var deletedSize = 0L var deletedNum = 0L val option = NodeListOption(includeFolder = false, deep = true) - val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, PathUtils.ROOT, option) + val criteria = NodeQueryHelper.nodeListCriteria(projectId, repoName, path, option) .and(TNode::createdDate).lt(date) val pageSize = 1 var queryCount: Int diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt index bd11d120bb..976b5a5d41 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt @@ -208,13 +208,15 @@ class CommitEdgeCenterNodeServiceImpl( projectId: String, repoName: String, date: LocalDateTime, - operator: String + operator: String, + path: String ): NodeDeleteResult { return CommitEdgeCenterNodeDeleteSupport(this, clusterProperties).deleteBeforeDate( projectId, repoName, date, - operator + operator, + path ) } diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt index 34479b7496..d8a46c4464 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt @@ -135,9 +135,10 @@ class EdgeNodeServiceImpl( projectId: String, repoName: String, date: LocalDateTime, - operator: String + operator: String, + path: String ): NodeDeleteResult { - return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator) + return NodeDeleteSupport(this).deleteBeforeDate(projectId, repoName, date, operator, path) } @Transactional(rollbackFor = [Throwable::class])