CompressUtil automatically decompress tgz and tar.gz files

This commit is contained in:
John Musk 2024-07-26 08:10:21 +09:00
parent 2384ea0425
commit cc69792280

View File

@ -183,6 +183,11 @@ public class CompressUtil {
return new SevenZExtractor(file); return new SevenZExtractor(file);
} }
try { 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); return new StreamExtractor(charset, archiverName, file);
} catch (final CompressException e) { } catch (final CompressException e) {
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();