ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs ZipTest.java
Date Thu, 27 Jun 2002 07:51:56 GMT
bodewig     2002/06/27 00:51:55

  Modified:    .        Tag: ANT_15_BRANCH WHATSNEW
               src/etc/testcases/taskdefs Tag: ANT_15_BRANCH zip.xml
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Zip.java
               src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_15_BRANCH ZipTest.java
  Log:
  Make sure that update="true" does what it is supposed to do in <zip>.
  
  PR: 8069
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.263.2.52 +9 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.263.2.51
  retrieving revision 1.263.2.52
  diff -u -r1.263.2.51 -r1.263.2.52
  --- WHATSNEW	22 Jun 2002 19:45:44 -0000	1.263.2.51
  +++ WHATSNEW	27 Jun 2002 07:51:55 -0000	1.263.2.52
  @@ -1,3 +1,12 @@
  +Changes from Ant 1.5beta3 to current CVS version
  +==============================================
  +
  +Fixed bugs:
  +-----------
  +
  +* <zip> and friends would always update existing archive if you set
  +  the update attribute to true.
  +
   Changes from Ant 1.5beta2 to Ant 1.5beta3
   =========================================
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.8.2.1   +17 -0     jakarta-ant/src/etc/testcases/taskdefs/zip.xml
  
  Index: zip.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/zip.xml,v
  retrieving revision 1.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- zip.xml	3 Mar 2002 06:52:07 -0000	1.8
  +++ zip.xml	27 Jun 2002 07:51:55 -0000	1.8.2.1
  @@ -78,6 +78,22 @@
       </zip>
     </target>
   
  +  <target name="testUpdateNotNecessary" depends="feather">
  +    <zip destFile="asf-logo.gif.zip"
  +         basedir=".."
  +         includes="asf-logo.gif"
  +         update="true" />
  +  </target>
  +
  +  <target name="testUpdateIsNecessary" depends="feather">
  +    <sleep seconds="5" />
  +    <touch file="../dummyfile" />
  +    <zip destFile="asf-logo.gif.zip"
  +         basedir=".."
  +         includes="asf-logo.gif,dummyfile"
  +         update="true" />
  +  </target>
  +
     <target name="cleanup">
       <delete file="test3.zip"/>
       <delete file="test4.zip"/>
  @@ -88,5 +104,6 @@
       <delete file="test8.zip"/>
       <delete file="asf-logo.gif.zip"/>
       <delete file="zipgroupfileset.zip"/>
  +    <delete file="../dummyfile" />
     </target>
   </project>
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.78.2.6  +20 -19    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.78.2.5
  retrieving revision 1.78.2.6
  diff -u -r1.78.2.5 -r1.78.2.6
  --- Zip.java	25 Jun 2002 06:48:32 -0000	1.78.2.5
  +++ Zip.java	27 Jun 2002 07:51:55 -0000	1.78.2.6
  @@ -292,22 +292,6 @@
   
           addingNewFiles = true;
           doUpdate = doUpdate && zipFile.exists();
  -        if (doUpdate) {
  -            FileUtils fileUtils = FileUtils.newFileUtils();
  -            renamedFile = 
  -                fileUtils.createTempFile("zip", ".tmp",
  -                                         fileUtils.getParentFile(zipFile));
  -
  -            try {
  -                if (!zipFile.renameTo(renamedFile)) {
  -                    throw new BuildException("Unable to rename old file to "
  -                                             + "temporary file");
  -                }
  -            } catch (SecurityException e) {
  -                throw new BuildException("Not allowed to rename old file to "
  -                                         + "temporary file");
  -            }
  -        }
   
           // Add the files found in groupfileset to fileset
           for (int i = 0; i < groupfilesets.size(); i++) {
  @@ -349,6 +333,23 @@
                   return;
               }
               
  +            if (doUpdate) {
  +                FileUtils fileUtils = FileUtils.newFileUtils();
  +                renamedFile = 
  +                    fileUtils.createTempFile("zip", ".tmp",
  +                                             fileUtils.getParentFile(zipFile));
  +
  +                try {
  +                    if (!zipFile.renameTo(renamedFile)) {
  +                        throw new BuildException("Unable to rename old file "
  +                                                 + "to temporary file");
  +                    }
  +                } catch (SecurityException e) {
  +                    throw new BuildException("Not allowed to rename old file "
  +                                             + "to temporary file");
  +                }
  +            }
  +
               String action = doUpdate ? "Updating " : "Building ";
               
               log(action + archiveType + ": " + zipFile.getAbsolutePath());
  @@ -419,13 +420,13 @@
               String msg = "Problem creating " + archiveType + ": " 
                   + ioe.getMessage();
   
  -            // delete a bogus ZIP file
  -            if (!zipFile.delete()) {
  +            // delete a bogus ZIP file (but only if it's not the original one)
  +            if ((!doUpdate || renamedFile != null) && !zipFile.delete()) {
                   msg += " (and the archive is probably corrupt but I could not "
                       + "delete it)";
               }
   
  -            if (doUpdate) {
  +            if (doUpdate && renamedFile != null) {
                   if (!renamedFile.renameTo(zipFile)) {
                       msg += " (and I couldn't rename the temporary file " +
                           renamedFile.getName() + " back)";
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.1   +9 -0      jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
  
  Index: ZipTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- ZipTest.java	11 Mar 2002 11:54:09 -0000	1.9
  +++ ZipTest.java	27 Jun 2002 07:51:55 -0000	1.9.2.1
  @@ -125,4 +125,13 @@
   
           zipFile.close();
       }
  +
  +    public void testUpdateNotNecessary() {
  +        executeTarget("testUpdateNotNecessary");
  +        assertEquals(-1, getLog().indexOf("Updating"));
  +    }
  +
  +    public void testUpdateIsNecessary() {
  +        expectLogContaining("testUpdateIsNecessary", "Updating");
  +    }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message