Skip to content

Commit b6fdc7b

Browse files
Add temp folder for import
Remove folder after import
1 parent db540ae commit b6fdc7b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77

88
Bugfixes:
99
- It should not be possible to delete Customer that assigned to the projects -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/9)
10+
- It is not possible to import several test run results one by one -> [View Issue](https://github.com/aquality-automation/aquality-tracking/issues/35)
1011

1112
## 0.3.3 (2019-11-16)
1213

src/main/java/main/utils/FileUtils.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public List<String> doUpload(HttpServletRequest request, HttpServletResponse res
5555

5656
public void removeFiles(List<String> filePaths){
5757
for (String path : filePaths){
58-
boolean delete = new File(path).delete();
58+
removeFile(path);
5959
}
6060
}
6161

6262
public void removeFile(String path){
63-
boolean delete = new File(path).delete();
63+
new File(path).delete();
6464
}
6565

6666
public String readFile(String path) throws AqualityException {
@@ -74,9 +74,8 @@ public String readFile(String path) throws AqualityException {
7474
}
7575
}
7676

77-
public String readFile(File file) throws IOException {
78-
InputStream is = new FileInputStream(file);
79-
return IOUtils.toString(is, "UTF-8");
77+
public String getFileFolderPath(String path) {
78+
return new File(path).getParent();
8079
}
8180

8281
private String getFileName(final Part part) {

src/main/java/main/view/Project/ExecuteImportServlet.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.servlet.http.HttpServletResponse;
2323
import java.io.IOException;
2424
import java.security.InvalidParameterException;
25+
import java.util.Date;
2526
import java.util.List;
2627

2728
@WebServlet("/import")
@@ -144,12 +145,16 @@ private void validateRequest() throws AqualityQueryParameterException {
144145

145146
private List<String> doUpload(HttpServletRequest req, HttpServletResponse resp, Integer projectId) throws ServletException, IOException {
146147
FileUtils fileUtils = new FileUtils();
147-
return fileUtils.doUpload(req, resp, PathUtils.createPathToBin("temp", projectId.toString()));
148+
return fileUtils.doUpload(req, resp, PathUtils.createPathToBin("temp", projectId.toString(), String.valueOf(new Date().getTime())));
148149
}
149150

150151
private void cleanup(List<String> filePaths){
151-
FileUtils fileUtils = new FileUtils();
152-
fileUtils.removeFiles(filePaths);
152+
if(filePaths.size() > 0) {
153+
FileUtils fileUtils = new FileUtils();
154+
String fileFolderPath = fileUtils.getFileFolderPath(filePaths.get(0));
155+
fileUtils.removeFiles(filePaths);
156+
fileUtils.removeFile(fileFolderPath);
157+
}
153158
}
154159

155160
private TestNameNodeType getTestNameNodeType(HttpServletRequest req) {

0 commit comments

Comments
 (0)