ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
Subject Re: Ant 1.7: unzip with overwrite set to 'false' is overwriting files
Date Wed, 08 Jul 2009 18:42:35 GMT
On Wed, Jul 8, 2009 at 2:22 PM, rdblaha1<rd_blaha@hotmail.com> wrote:
>
> Thank you David for pointing out the OLDER vs. NEWER timestamp.  The
> timestamp of the existing files is always OLDER in my testing.

Would using the <touch> task help? Before unzipping, you can "touch"
all the properties files that you don't want to overwrite, giving them
a newer timestamp than the files inside the zipfile.

Of course, you'll destroy the previous dates, but it will help prevent
overwriting.

The other possibility is to test for the config properties files, and
if they don't exist, unzip normally. If they do exist, use the exclude
pattern. Here's a very rough and untested way of doing it:

The unzip task now simply tests to see whether or not you have
properties files. If you do, you do the unzip.selected and skip
unpacking the properties files. If you don't, you use the "unzip.all"
task and skip over the properties files.

Of course, this assumes that you either have all the properties files
or none of them:

<target name="unzip"
    <fileset id="config.files" dir="${TMP_DIR}/config">
          <include name="*.properties"/>
    </fileset>

    <condition property="config.properties.exist">
        <resourcecount refid="config.files" when="greater" count="0"/>
   </condition>

    depends="unzip.test">
    <antcall target=unzip.all/>
    <antcall target="unzip.selected"/>
</target>

<target name="unzip.all"
    unless="config.properties.exist">

</target>

<target name="unzip.selected">
    if="config.properties.exist>

</target>

Try the <touch> task first and see if that  will fix your issue.

>
> My problem isn't solved with the patternset as I previously thought.  If my
> config properties files don't exist in the dest directory in the first place
> I DO want them there.  The patternset will always exclude them whether they
> exist or not.   I need someway to just simply NOT overwrite them if they
> exist OLDER or NEWER timestamp.  In that case what would you suggest?
>
> Thanks again David,
> Rick Blaha
>
>
>
> David Weintraub wrote:
>>
>> Quick question: What is the timestamp on these files?
>>
>> If you set the overwrite parameter to false, it may be overwriting
>> files that have an OLDER timestamp than the file that's replacing it.
>>
>> The description of this parameter is:
>>
>>     Overwrite files, even if they are newer than the corresponding entries
>>     in the archive (true or false, default is true).
>>
>
> --
> View this message in context: http://www.nabble.com/Ant-1.7%3A--unzip-with-overwrite-set-to-%27false%27-is-overwriting-files-tp24393106p24396800.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
David Weintraub
qazwart@gmail.com

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


Mime
View raw message