Merge pull request #3674 from zdu-strong/v6-dev-compress-util

CompressUtil automatically decompress tgz and tar.gz files
This commit is contained in:
Golden Looly 2024-07-31 00:30:22 +08:00 committed by GitHub
commit 72ac17e41e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,6 +183,11 @@ public class CompressUtil {
return new SevenZExtractor(file);
}
try {
if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tgz")) {
archiverName = "tgz";
} else if (StrUtil.isBlank(archiverName) && file.getName().toLowerCase().endsWith(".tar.gz")) {
archiverName = "tar.gz";
}
return new StreamExtractor(charset, archiverName, file);
} catch (final CompressException e) {
final Throwable cause = e.getCause();