diff --git a/src/main/java/de/devloop/mavor/servlet/DownloadZip.java b/src/main/java/de/devloop/mavor/servlet/DownloadZip.java index 266246f..caa2c18 100644 --- a/src/main/java/de/devloop/mavor/servlet/DownloadZip.java +++ b/src/main/java/de/devloop/mavor/servlet/DownloadZip.java @@ -23,15 +23,21 @@ public class DownloadZip extends AuthenticatedServlet { protected void doAuthenticatedGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String zipFilename = req.getParameter(PARAMETER_FILENAME); File zipFile = new File(tempDir, zipFilename); - if (zipFile.getParentFile().getCanonicalPath().equals(tempDir.getCanonicalPath())) { - resp.addHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", zipFilename)); - resp.setContentType("application/zip"); - resp.setContentLengthLong(zipFile.length()); - FileInputStream fileInputStream = new FileInputStream(zipFile); - fileInputStream.transferTo(resp.getOutputStream()); - fileInputStream.close(); + + if (zipFile.exists()) { + if (zipFile.getParentFile().getCanonicalPath().equals(tempDir.getCanonicalPath())) { + resp.addHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", zipFilename)); + resp.setContentType("application/zip"); + resp.setContentLengthLong(zipFile.length()); + FileInputStream fileInputStream = new FileInputStream(zipFile); + fileInputStream.transferTo(resp.getOutputStream()); + fileInputStream.close(); + zipFile.delete(); + } else { + throw new ServletException("-.-"); + } } else { - throw new ServletException("-.-"); + resp.sendRedirect("/mavor"); } } } diff --git a/src/main/webapp/download.jsp b/src/main/webapp/download.jsp index 4a15f09..7de790a 100644 --- a/src/main/webapp/download.jsp +++ b/src/main/webapp/download.jsp @@ -2,9 +2,9 @@ <%@ page isELIgnored="false" %>
- Output:${stdout}
${stdout}