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),是否可按浏览器规则 修改了重名规则 添加了异常处理
newui
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); File fileNeedOpen = new File(fileName);
if (fileName.endsWith(FineMarketConstants.ZIP)) { if (fileName.endsWith(FineMarketConstants.ZIP)) {
File[] files = fileNeedOpen.listFiles(); File[] files = fileNeedOpen.getParentFile().listFiles();
fileNeedOpen = getFirstCptOrFrm(files); fileNeedOpen = getFirstCptOrFrm(files);
} else if (fileName.endsWith(FineMarketConstants.RAR)) { } else if (fileName.endsWith(FineMarketConstants.RAR)) {
// 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -154,18 +155,20 @@ public class FineMarketClientHelper {
* */ * */
private File createDestFile(File destDir, TemplateResource resource) { private File createDestFile(File destDir, TemplateResource resource) {
String fileName = resource.getName(); String fileName = resource.getName();
File finalDir = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(destDir), fileName));
try { try {
File finalDir = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(destDir), fileName));
if (!finalDir.exists()) { if (!finalDir.exists()) {
finalDir.mkdir(); finalDir.mkdir();
} }
// 获取文件名(含后缀) // 获取文件名(含后缀)
fileName = resource.getFileName(); fileName = resource.getFileName();
String prefix = fileName.substring(0, fileName.length() - 4);
String suffix = fileName.substring(fileName.length() - 4);
// 处理重复文件名 // 处理重复文件名
String fileNameFormat = "(%d)" + fileName; String fileNameFormat = prefix + "(%d)" + suffix;
Pattern pattern = Pattern.compile("\\((\\d)\\)" + fileName); Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix);
int cnt = 0; int cnt = 0;
File[] files = finalDir.listFiles(); File[] files = finalDir.listFiles();
@ -178,15 +181,14 @@ public class FineMarketClientHelper {
cnt++; cnt++;
fileName = String.format(fileNameFormat, cnt); fileName = String.format(fileNameFormat, cnt);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName)); File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
destFile.createNewFile();
return destFile; return destFile;
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); 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 { private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {

Loading…
Cancel
Save