refactor: Remove Redundant Validation in File Encryption Process
This commit is contained in:
parent
344003339e
commit
09fd83bc31
@ -8,8 +8,6 @@ import java.io.InputStream;
|
||||
import cn.idev.excel.exception.ExcelAnalysisException;
|
||||
import cn.idev.excel.exception.ExcelCommonException;
|
||||
import cn.idev.excel.read.metadata.ReadWorkbook;
|
||||
import cn.idev.excel.util.StringUtils;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
||||
@ -59,12 +57,6 @@ public enum ExcelTypeEnum {
|
||||
if (!file.exists()) {
|
||||
throw new ExcelAnalysisException("File " + file.getAbsolutePath() + " not exists.");
|
||||
}
|
||||
// If there is a password, use the FileMagic first
|
||||
if (!StringUtils.isEmpty(readWorkbook.getPassword())) {
|
||||
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||
return recognitionExcelType(bufferedInputStream);
|
||||
}
|
||||
}
|
||||
// Use the name to determine the type
|
||||
String fileName = file.getName();
|
||||
if (fileName.endsWith(XLSX.getValue())) {
|
||||
@ -74,10 +66,8 @@ public enum ExcelTypeEnum {
|
||||
} else if (fileName.endsWith(CSV.getValue())) {
|
||||
return CSV;
|
||||
}
|
||||
if (StringUtils.isEmpty(readWorkbook.getPassword())) {
|
||||
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||
return recognitionExcelType(bufferedInputStream);
|
||||
}
|
||||
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||
return recognitionExcelType(bufferedInputStream);
|
||||
}
|
||||
}
|
||||
if (!inputStream.markSupported()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user