You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2004/01/26 19:57:53 UTC

DO NOT REPLY [Bug 26443] New: - zip update=false does not overwrite zip file when file deleted

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26443>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26443

zip update=false does not overwrite zip file when file deleted

           Summary: zip update=false does not overwrite zip file when file
                    deleted
           Product: Ant
           Version: 1.6.0
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: mlottman@carefx.com


According to the javadoc for zip, if you set update=false, the zip task should 
overwrite the destination zip file.  I have found that this is not the case.

I have included an example below that shows that deleting a file and re-
zipping does not overwrite the destination zip file.  After running the test, 
view the zip file, and you will notice it still contains file1.txt. If I give 
the zip a new file name, or remove the old zip first, everything works as 
expected.

<project name="ZipOverwriteProblem" default="test" basedir=".">
    <description>
        Zip with update=false is not overwritting zip files
        when a file is deleted.
    </description>

    <target name="test" depends="clean">
        <!-- Create a few test files to zip -->
        <touch file="file1.txt"/>
        <touch file="file2.txt"/>
        
        <!-- Zip the files -->
        <zip destfile="test.zip"
             basedir="."
             includes="file1.txt,file2.txt"/>
                
        <!-- Extract the zip into a tmp directory and delete
             file1.txt -->
        <mkdir dir="tmpw"/>
        <unzip src="test.zip" dest="tmpw"/>
        <delete file="tmpw/file1.txt"/>      

        <!-- Replace test.zip with a new zip that contains the
             contents of tmpw.  This does not work properly.
             test.zip ends up still containing file1.txt!!
             According to the zip java doc, if update=false, 
             the zip file should be overwritten.
             -->
        <echo message="Overwriting test.zip file"/>
        <echo message="Manually verify it no longer contains file1.txt"/>
        <zip destfile="test.zip" 
             update="false"
             basedir="tmpw"/>
        
    </target>

    <target name="clean">
        <delete>
            <fileset dir=".">
                <include name="file1.txt"/>
                <include name="file2.txt"/>
                <include name="test.zip"/>
                <include name="tmpw/**"/>
            </fileset>
        </delete>
    </target>
</project>

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