|
|
@@ -59,7 +59,7 @@ public class FileServiceImpl implements FileService {
|
|
|
// 不支持查看、压缩:jasper文件、tmp路径
|
|
|
String filePath = file.getPath().toLowerCase();
|
|
|
if (filePath.endsWith(".jasper") || filePath.endsWith("tmp") || filePath.contains("\\tmp\\")
|
|
|
- || filePath.contains("/tmp/")) {
|
|
|
+ || filePath.contains("/tmp/") || filePath.endsWith(".bak")) {
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
@@ -90,7 +90,7 @@ public class FileServiceImpl implements FileService {
|
|
|
String[] userNameArray = destinationUserNames.split(",");
|
|
|
// 创建账套路径并解压模板zip包
|
|
|
for (String userName : userNameArray) {
|
|
|
- ZipUtils.unzip(data, getMasterPath(userName));
|
|
|
+ ZipUtils.unzip(data, getMasterPath(userName), true);
|
|
|
}
|
|
|
return "已自动部署:" + destinationUserNames;
|
|
|
}
|
|
|
@@ -113,7 +113,7 @@ public class FileServiceImpl implements FileService {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
try {
|
|
|
- ZipUtils.unzip(file.getBytes(), getMasterPath(userName));
|
|
|
+ ZipUtils.unzip(file.getBytes(), getMasterPath(userName), true);
|
|
|
} catch (IOException e) {
|
|
|
throw new IllegalStateException("文件解压失败", e);
|
|
|
}
|
|
|
@@ -142,6 +142,7 @@ public class FileServiceImpl implements FileService {
|
|
|
targetFile.getParentFile().mkdirs();
|
|
|
}
|
|
|
try {
|
|
|
+ FileUtils.backup(targetFile);
|
|
|
FileUtils.write(targetFile.getAbsolutePath(), file.getBytes(), true);
|
|
|
return "成功上传文件至:" + targetFile.getPath();
|
|
|
} catch (IllegalStateException | IOException e) {
|
|
|
@@ -170,7 +171,8 @@ public class FileServiceImpl implements FileService {
|
|
|
// 因为在spring boot下上传文件时会对临时路径进行处理,
|
|
|
// 导致最终文件路径不正确,如果手动设置临时路径为根路径,
|
|
|
// 又会因为权限问题导致文件写入失败,
|
|
|
- // 所以自己在指定路径创建文件,而不使用transferTo方法
|
|
|
+ // 所以改为在指定路径创建文件,而不使用transferTo方法
|
|
|
+ FileUtils.backup(targetFile);
|
|
|
FileUtils.write(targetFile.getAbsolutePath(), file.getBytes(), true);
|
|
|
stringBuilder.append("上传成功:").append(fileName).append("\n");
|
|
|
}
|