|
|
@@ -48,6 +48,25 @@ public class FileServiceImpl implements FileService {
|
|
|
|
|
|
private Logger logger = Logger.getLogger(getClass());
|
|
|
|
|
|
+ /**
|
|
|
+ * 查看、压缩文件时,对文件进行过滤
|
|
|
+ */
|
|
|
+ private FileFilter fileFilter = new FileFilter() {
|
|
|
+ @Override
|
|
|
+ public boolean accept(File file) {
|
|
|
+ if (file == null || !file.exists()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 不支持查看、压缩:zip、jasper文件、tmp路径
|
|
|
+ String filePath = file.getPath();
|
|
|
+ if (filePath.endsWith(".zip") || filePath.endsWith(".jasper") || filePath.endsWith("tmp")
|
|
|
+ || filePath.contains("\\tmp\\") || filePath.contains("/tmp/")) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
@Override
|
|
|
public String autoDeploy(String userNames) {
|
|
|
logger.info("request... " + userNames);
|
|
|
@@ -181,16 +200,6 @@ public class FileServiceImpl implements FileService {
|
|
|
String folderPath = getMasterPath(userName);
|
|
|
// 压缩后的压缩包路径,与账套在同一级
|
|
|
String zipFilePath = folderPath + ".zip";
|
|
|
- FileFilter fileFilter = new FileFilter() {
|
|
|
- @Override
|
|
|
- public boolean accept(File pathname) {
|
|
|
- // 对zip、jasper文件不进行压缩
|
|
|
- if (pathname.getPath().endsWith(".zip") || pathname.getPath().endsWith(".jasper")) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
ZipUtils.zipFolder(folderPath, zipFilePath, fileFilter);
|
|
|
return zipFilePath;
|
|
|
}
|
|
|
@@ -276,16 +285,6 @@ public class FileServiceImpl implements FileService {
|
|
|
if (file.isFile()) {
|
|
|
result.add(getFileInformation(file));
|
|
|
} else {
|
|
|
- FileFilter fileFilter = new FileFilter() {
|
|
|
- @Override
|
|
|
- public boolean accept(File pathname) {
|
|
|
- // 不显示zip压缩包、jasper文件的信息
|
|
|
- if (pathname.getPath().endsWith(".zip") || pathname.getPath().endsWith(".jasper")) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
File[] files = file.listFiles(fileFilter);
|
|
|
// 文件夹放在前面展示
|
|
|
List<File> directoryList = new ArrayList<>();
|