Commit d7f9e802 by zhongmh

增加删除项目重定向功能

parent 1a6d0be3
......@@ -122,8 +122,8 @@ public class SystemFile {
File[] listFiles = currentFile.listFiles();
if (listFiles == null || listFiles.length == 0) {
// 说明是空文件夹直接删除
currentFile.deleteOnExit();
} else{
currentFile.delete();
} else {
fileStack.push(currentFile);
for (File file : listFiles) {
if (file.isDirectory() && file.listFiles().length > 0) {
......@@ -137,7 +137,7 @@ public class SystemFile {
}
} else {
currentFile.deleteOnExit();
currentFile.delete();
}
}
}
......
......@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.*;
......@@ -56,9 +58,9 @@ public class IndexController {
@ResponseBody
@GetMapping("del/{project}")
public String del(@PathVariable("project") String project) throws IOException {
public void del(@PathVariable("project") String project, HttpServletResponse response) throws IOException {
logger.info("当前正在删除项目:{}",project);
systemFile.cleanFile(project);
return index();
response.sendRedirect("/");
}
}
......@@ -14,7 +14,7 @@ public class SystemFileTest {
public void cleanFile(){
SystemFile systemFile = new SystemFile("E:\\tmp");
systemFile.cleanFile("logs");
systemFile.cleanFile("openjdk-8u40-src-b25-10_feb_2015");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment