You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@locus.apache.org on 2000/08/03 11:13:18 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Zip.java

bodewig     00/08/03 02:13:18

  Modified:    src/main/org/apache/tools/ant/taskdefs Zip.java
  Log:
  Delete the corrupt ZIP-file if <zip> or <jar> tasks fail.
  Submitted by:	Jesse Glick <Je...@netbeans.com>
  
  Revision  Changes    Path
  1.10      +12 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Zip.java	2000/07/10 07:29:26	1.9
  +++ Zip.java	2000/08/03 09:13:18	1.10
  @@ -145,6 +145,18 @@
               }
           } 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) {