diff --git a/src/main/java/org/t246osslab/easybuggy/troubles/UnrestrictedUploadServlet.java b/src/main/java/org/t246osslab/easybuggy/troubles/UnrestrictedUploadServlet.java index 7b40b904..2548717f 100644 --- a/src/main/java/org/t246osslab/easybuggy/troubles/UnrestrictedUploadServlet.java +++ b/src/main/java/org/t246osslab/easybuggy/troubles/UnrestrictedUploadServlet.java @@ -81,6 +81,7 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se doGet(req, res); } // TODO Remove this try block that is a workaround of issue #9 (FileNotFoundException on Jetty * Windows) + boolean isConverted = false; try { out = new FileOutputStream(savePath + File.separator + fileName); in = filePart.getInputStream(); @@ -91,16 +92,18 @@ protected void doPost(HttpServletRequest req, HttpServletResponse res) throws Se } } catch (FileNotFoundException e) { // Ignore because file already exists + isConverted = true; } - boolean isConverted = true; try { // Reverse the color of the upload image - revereColor(new File(savePath + File.separator + fileName).getAbsolutePath()); + if(!isConverted){ + revereColor(new File(savePath + File.separator + fileName).getAbsolutePath()); + isConverted = true; + } } catch (Exception e) { // Log and ignore the exception log.warn("Exception occurs: ", e); - isConverted = false; } StringBuilder bodyHtml = new StringBuilder();