refactor(用例管理): 获取下载文件的权限

This commit is contained in:
guoyuqi 2024-08-09 13:12:38 +08:00 committed by 刘瑞斌
parent 9b954e3abb
commit 3601f8a6c0
2 changed files with 3 additions and 4 deletions

View File

@ -52,7 +52,7 @@ public class XMindParser {
File dir = new File(res); File dir = new File(res);
FileUtils.deleteDirectory(dir); FileUtils.deleteDirectory(dir);
} }
// 删除时文件 // 删除时文件
if (file != null) { if (file != null) {
file.delete(); file.delete();
} }

View File

@ -3,6 +3,7 @@ package io.metersphere.functional.xmind.parser;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.examples.Expander; import org.apache.commons.compress.archivers.examples.Expander;
import org.apache.commons.io.FileUtils;
import java.io.*; import java.io.*;
import java.util.HashMap; import java.util.HashMap;
@ -15,8 +16,6 @@ import java.util.Objects;
*/ */
public class ZipUtils { public class ZipUtils {
private static final String CURRENT_PATH = System.getProperty("user.dir");
/** /**
* 找到压缩文件中匹配的子文件返回的为 getContents("comments.xml, unzip * 找到压缩文件中匹配的子文件返回的为 getContents("comments.xml, unzip
* *
@ -44,7 +43,7 @@ public class ZipUtils {
*/ */
public static String extract(File file) throws IOException, ArchiveException { public static String extract(File file) throws IOException, ArchiveException {
Expander expander = new Expander(); Expander expander = new Expander();
String destFileName = CURRENT_PATH + File.separator + "XMind" + System.currentTimeMillis(); String destFileName = FileUtils.getTempDirectoryPath()+ File.separator + "XMind" + System.currentTimeMillis();
expander.expand(file, new File(destFileName)); expander.expand(file, new File(destFileName));
return destFileName; return destFileName;
} }