Browse Source

Pull request #9884: REPORT-79341 【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则

Merge in DESIGN/design from ~LINK.ZHAO/design:release/11.0 to release/11.0

* commit '823fa786038cb81b56f78ee895afd5754b32d16a':
  REPORT-79341 【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则 修改了重名规则 添加了异常处理
release/11.0
Link.Zhao 2 years ago
parent
commit
494d0f0a0f
  1. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java
  2. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java

@ -60,7 +60,7 @@ public class StartUseAction implements ActionListener {
}
File fileNeedOpen = new File(fileName);
if (fileName.endsWith(FineMarketConstants.ZIP)) {
File[] files = fileNeedOpen.listFiles();
File[] files = fileNeedOpen.getParentFile().listFiles();
fileNeedOpen = getFirstCptOrFrm(files);
} else if (fileName.endsWith(FineMarketConstants.RAR)) {
// rar直接打开系统文件夹

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -154,18 +155,20 @@ public class FineMarketClientHelper {
* */
private File createDestFile(File destDir, TemplateResource resource) {
String fileName = resource.getName();
try {
File finalDir = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(destDir), fileName));
try {
if (!finalDir.exists()) {
finalDir.mkdir();
}
// 获取文件名(含后缀)
fileName = resource.getFileName();
String prefix = fileName.substring(0, fileName.length() - 4);
String suffix = fileName.substring(fileName.length() - 4);
// 处理重复文件名
String fileNameFormat = "(%d)" + fileName;
Pattern pattern = Pattern.compile("\\((\\d)\\)" + fileName);
String fileNameFormat = prefix + "(%d)" + suffix;
Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix);
int cnt = 0;
File[] files = finalDir.listFiles();
@ -178,15 +181,14 @@ public class FineMarketClientHelper {
cnt++;
fileName = String.format(fileNameFormat, cnt);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
destFile.createNewFile();
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return null;
fileName = UUID.randomUUID() + fileName;
File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return dest;
}
private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {

Loading…
Cancel
Save