Merge pull request #3673 from zdu-strong/v5-dev-compress-util

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

View File

@ -171,6 +171,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 (CompressException e) {
final Throwable cause = e.getCause();