Browse Source

Delete the corrupt ZIP-file if <zip> or <jar> tasks fail.

Submitted by:	Jesse Glick <Jesse.Glick@netbeans.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267877 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
e7e63a0e7a
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 12
- 0
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -145,6 +145,18 @@ public class Zip extends MatchingTask {
} }
} catch (IOException ioe) { } catch (IOException ioe) {
String msg = "Problem creating " + archiveType + " " + ioe.getMessage(); 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); throw new BuildException(msg, ioe, location);
} finally { } finally {
if (zOut != null) { if (zOut != null) {


Loading…
Cancel
Save