From d56ac721d82e424134abfb8fa0ef63ba30a2160a Mon Sep 17 00:00:00 2001 From: yaoxuwan Date: Fri, 8 Mar 2024 16:47:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=8D=E8=A7=84=E8=8C=83=E7=9A=84?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=8C=85=E9=A2=84=E8=A7=88=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=20#1854?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bkrepo/generic/service/CompressedFileService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/service/CompressedFileService.kt b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/service/CompressedFileService.kt index 6516568b61..19628f4d54 100644 --- a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/service/CompressedFileService.kt +++ b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/service/CompressedFileService.kt @@ -27,6 +27,7 @@ package com.tencent.bkrepo.generic.service +import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.artifact.exception.ArtifactNotFoundException import com.tencent.bkrepo.common.artifact.exception.NodeNotFoundException @@ -43,6 +44,7 @@ import com.tencent.bkrepo.generic.artifact.GenericArtifactInfo import com.tencent.bkrepo.generic.pojo.CompressedFileInfo import com.tencent.bkrepo.repository.api.NodeClient import org.apache.commons.compress.archivers.ArchiveEntry +import org.apache.commons.compress.archivers.ArchiveException import org.apache.commons.compress.archivers.ArchiveInputStream import org.apache.commons.compress.archivers.ArchiveStreamFactory import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream @@ -122,7 +124,11 @@ class CompressedFileService( if (fileExtension == GZ_FILE_TYPE || fileExtension == TGZ_FILE_TYPE) { inputStream = GzipCompressorInputStream(inputStream) } - return ArchiveStreamFactory().createArchiveInputStream(BufferedInputStream(inputStream)) + return try { + ArchiveStreamFactory().createArchiveInputStream(BufferedInputStream(inputStream)) + } catch (e: ArchiveException) { + throw ErrorCodeException(ArtifactMessageCode.ARTIFACT_TYPE_UNSUPPORTED, StringPool.UNKNOWN) + } } }