From 1113e76a387cd21a3222d7b462f8a595f9260134 Mon Sep 17 00:00:00 2001 From: felixncheng Date: Thu, 26 Sep 2024 16:52:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bug:=20media=E6=9C=8D=E5=8A=A1=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=AE=A4=E8=AF=81=E5=A4=B1=E8=B4=A5=20#2616?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkrepo/common/security/manager/PermissionManager.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/common/common-security/src/main/kotlin/com/tencent/bkrepo/common/security/manager/PermissionManager.kt b/src/backend/common/common-security/src/main/kotlin/com/tencent/bkrepo/common/security/manager/PermissionManager.kt index 1c03eb321d..24eb4ee074 100644 --- a/src/backend/common/common-security/src/main/kotlin/com/tencent/bkrepo/common/security/manager/PermissionManager.kt +++ b/src/backend/common/common-security/src/main/kotlin/com/tencent/bkrepo/common/security/manager/PermissionManager.kt @@ -73,6 +73,7 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody import org.slf4j.LoggerFactory +import org.springframework.web.context.request.RequestContextHolder import java.io.IOException import java.util.concurrent.TimeUnit @@ -360,9 +361,11 @@ open class PermissionManager( path = paths?.first(), ) // devx 是否需要auth 校验仓库维度的访问黑名单 - val devxAccessFrom = HttpContextHolder.getRequest().getAttribute(HEADER_DEVX_ACCESS_FROM) - if (devxAccessFrom == DEVX_ACCESS_FROM_OFFICE) { - checkRequest.requestSource = DEVX_ACCESS_FROM_OFFICE + if (RequestContextHolder.getRequestAttributes() != null) { + val devxAccessFrom = HttpContextHolder.getRequest().getAttribute(HEADER_DEVX_ACCESS_FROM) + if (devxAccessFrom == DEVX_ACCESS_FROM_OFFICE) { + checkRequest.requestSource = DEVX_ACCESS_FROM_OFFICE + } } if (checkPermissionFromAuthService(checkRequest) != true) { // 无权限,响应403错误 From 78aeb7180090c6f0052dcecb760411dc543bf997 Mon Sep 17 00:00:00 2001 From: felixncheng Date: Thu, 26 Sep 2024 18:12:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E8=BD=AC=E7=A0=81=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E6=94=AF=E6=8C=81=E4=BF=9D=E7=95=99=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=20#2598?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkrepo/media/service/TranscodeService.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt index d04f2ad82f..75d5ac62e0 100644 --- a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt +++ b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt @@ -16,6 +16,8 @@ import com.tencent.bkrepo.media.config.MediaProperties import com.tencent.bkrepo.media.stream.TranscodeParam import com.tencent.bkrepo.media.stream.TranscodeConfig import com.tencent.bkrepo.media.stream.TranscodeHelper +import com.tencent.bkrepo.repository.api.MetadataClient +import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -23,7 +25,11 @@ import org.springframework.stereotype.Service * 视频转码服务 * */ @Service -class TranscodeService(private val tokenService: TokenService, private val mediaProperties: MediaProperties) : +class TranscodeService( + private val tokenService: TokenService, + private val mediaProperties: MediaProperties, + private val metadataClient: MetadataClient, +) : ArtifactService() { /** @@ -63,6 +69,13 @@ class TranscodeService(private val tokenService: TokenService, private val media val context = ArtifactUploadContext(repo, newArtifactFile, newArtifactInfo) repository.upload(context) logger.info("Upload new file[$newArtifactInfo]") + // 复制原有视频的metadata + val originMetadata = + metadataClient.listMetadata(projectId, repoName, originArtifactInfo.getArtifactFullPath()).data + originMetadata?.let { + val copyRequest = MetadataSaveRequest(projectId, repoName, newArtifactInfo.getArtifactFullPath(), it) + metadataClient.saveMetadata(copyRequest) + } val removeContext = ArtifactRemoveContext(repo, originArtifactInfo) repository.remove(removeContext) logger.info("Delete origin file[$originArtifactInfo]")