fix: Fix .tgz file decompression exception issue (#9974)

#9927
This commit is contained in:
2025-08-13 15:38:51 +08:00 committed by GitHub
parent b706774b5b
commit ec01aef71a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -3,6 +3,7 @@ export enum CompressType {
Gz = 'gz',
Bz2 = 'bz2',
Tar = 'tar',
TGz = 'tgz',
TarGz = 'tar.gz',
Xz = 'xz',
Rar = 'rar',
@ -14,6 +15,7 @@ export enum CompressExtension {
gz = '.gz',
bz2 = '.tar.bz2',
tar = '.tar',
tgz = '.tgz',
'tar.gz' = '.tar.gz',
xz = '.tar.xz',
rar = '.rar',
@ -26,6 +28,7 @@ export const MimetypeByExtensionObject: Record<string, string> = {
'.tar.bz2': 'application/x-bzip2',
'.bz2': 'application/x-bzip2',
'.tar.gz': 'application/gzip',
'.tgz': 'application/x-gzip',
'.gz': 'application/gzip',
'.xz': 'application/x-xz',
'.rar': 'application/x-rar-compressed',

View file

@ -1033,11 +1033,9 @@ const openDeCompress = (item: File.File) => {
MsgWarning(i18n.global.t('file.canNotDeCompress'));
return;
}
fileDeCompress.mimeType = item.mimeType;
if (CompressExtension[Mimetypes.get(item.mimeType)] != item.extension) {
fileDeCompress.mimeType = MimetypeByExtensionObject[item.extension];
} else {
fileDeCompress.mimeType = item.mimeType;
}
fileDeCompress.name = item.name;