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错误 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]")