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.ExcelAnalysisException;
|
||||||
import cn.idev.excel.exception.ExcelCommonException;
|
import cn.idev.excel.exception.ExcelCommonException;
|
||||||
import cn.idev.excel.read.metadata.ReadWorkbook;
|
import cn.idev.excel.read.metadata.ReadWorkbook;
|
||||||
import cn.idev.excel.util.StringUtils;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
|
|
||||||
@ -59,12 +57,6 @@ public enum ExcelTypeEnum {
|
|||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new ExcelAnalysisException("File " + file.getAbsolutePath() + " not 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
|
// Use the name to determine the type
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
if (fileName.endsWith(XLSX.getValue())) {
|
if (fileName.endsWith(XLSX.getValue())) {
|
||||||
@ -74,12 +66,10 @@ public enum ExcelTypeEnum {
|
|||||||
} else if (fileName.endsWith(CSV.getValue())) {
|
} else if (fileName.endsWith(CSV.getValue())) {
|
||||||
return CSV;
|
return CSV;
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(readWorkbook.getPassword())) {
|
|
||||||
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
|
try (BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(file))) {
|
||||||
return recognitionExcelType(bufferedInputStream);
|
return recognitionExcelType(bufferedInputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!inputStream.markSupported()) {
|
if (!inputStream.markSupported()) {
|
||||||
inputStream = new BufferedInputStream(inputStream);
|
inputStream = new BufferedInputStream(inputStream);
|
||||||
readWorkbook.setInputStream(inputStream);
|
readWorkbook.setInputStream(inputStream);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user