Skip to content

Commit

Permalink
fix: 不规范的压缩包预览失败 TencentBlueKing#1854
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxuwan authored Mar 8, 2024
1 parent 42b45e0 commit d56ac72
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit d56ac72

Please sign in to comment.