From e7e63a0e7a7cb40a720e48b3a7477d3d3bbd94d1 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 3 Aug 2000 09:13:18 +0000 Subject: [PATCH] Delete the corrupt ZIP-file if or tasks fail. Submitted by: Jesse Glick git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267877 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Zip.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index 70649c529..0979341d2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -145,6 +145,18 @@ public class Zip extends MatchingTask { } } catch (IOException ioe) { String msg = "Problem creating " + archiveType + " " + ioe.getMessage(); + + // delete a bogus ZIP file + if (zOut != null) { + try { + zOut.close(); + zOut = null; + } catch (IOException e) {} + if (!zipFile.delete()) { + msg = zipFile + " is probably corrupt but I could not delete it"; + } + } + throw new BuildException(msg, ioe, location); } finally { if (zOut != null) {