You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2010/05/07 00:04:40 UTC
DO NOT REPLY [Bug 49261] New: Copy task fails to overwrite readonly
files even with overwrite="true"
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Summary: Copy task fails to overwrite readonly files even with
overwrite="true"
Product: Ant
Version: 1.8.0
Platform: Macintosh
Status: NEW
Severity: regression
Priority: P2
Component: Core tasks
AssignedTo: notifications@ant.apache.org
ReportedBy: carl.quinn@gmail.com
The copy task in prior versions (I tried 1.7.0 & 1.7.1) allowed one to
overwrite a read-only file if overwrite="true" was set. Now it seems that in
1.8.0 that no longer works and results in an exception:
/private/tmp/build.xml:3: Failed to copy /private/tmp/source to
/private/tmp/dest due to java.io.FileNotFoundException /private/tmp/dest
(Permission denied)
My steps to reproduce are below.
$ whoami
cquinn
$ echo 'The quick brown fox jumped over the lazy dog.' > source
$ touch dest; chmod -w dest
$ ls -l source dest
-r--r--r-- 1 cquinn wheel 0 May 6 14:39 dest
-rw-r--r-- 1 cquinn wheel 46 May 6 14:35 source
$ cat build.xml
<project default="bug">
<target name="bug">
<copy file="source" tofile="dest" overwrite="true"/>
</target>
</project>
$ ant -version
Apache Ant version 1.8.0 compiled on February 1 2010
$ ant
Buildfile: /private/tmp/build.xml
bug:
[copy] Copying 1 file to /private/tmp
BUILD FAILED
/private/tmp/build.xml:3: Failed to copy /private/tmp/source to
/private/tmp/dest due to java.io.FileNotFoundException /private/tmp/dest
(Permission denied)
$ ls -l source dest
ls: dest: No such file or directory
-rw-r--r-- 1 cquinn wheel 46 May 6 14:35 source
>> Note that it not only failed to copy, but it removed the file.
>> Now, put the dest file back and switch ants to show how it used to work:
$ touch dest; chmod -w dest
$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
$ ant
Buildfile: build.xml
bug:
[copy] Copying 1 file to /private/tmp
BUILD SUCCESSFUL
Total time: 0 seconds
$ ls -l source dest
-rw-r--r-- 1 cquinn wheel 46 May 6 14:57 dest
-rw-r--r-- 1 cquinn wheel 46 May 6 14:35 source
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #5 from Stefan Bodewig <bo...@apache.org> 2010-05-11 05:54:50 EDT ---
<move> has been adapted with svn revision 943056 and <concat> and <echo>
with svn revision 943068
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS/Version| |All
--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2010-05-07 05:14:26 EDT ---
My guess is that our changed copy code using NIO is taking the target's
permissions into account whlie the old stream based approach did not.
overwrite really only says "write even if the dest isn't out of date" and never
had any influence on whether a readonly dest file would get overwritten.
If you create dest befaore source in your testcase Ant 1.7.1 will happily
overwrite dest without the overwrite attribute as well.
I must admit that I actually like the change - Ant shouldn't ignore the
read-only state if the destination. We may want to throw in an additional
attribute that controls the behavior.
If my guess is correct then you can trick Ant into using the non-NIO code
by filtering- i.e. you could throw in a filter that doesn't change your
files. This will not work for binary files. Another "trick" would be to
ZIP or TAR up the sources and extract from there since the NIO code
is only used if source and dest are files and no filtering occurs at all.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
--- Comment #3 from Stefan Bodewig <bo...@apache.org> 2010-05-07 10:36:11 EDT ---
(In reply to comment #2)
> in revision 942805
should have been svn revision 942085
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |1.8.2
--- Comment #4 from Stefan Bodewig <bo...@apache.org> 2010-05-10 10:46:21 EDT ---
With svn revision 942752 <copy> behaves consistently and has a new attribute
"force" that can be used to overwrite read-only destinations.
I'll check the other clients of out "copy" method to see which other tasks
would need a force attribute as well before I close this.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Antoine Levy-Lambert <an...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|1.8.0 |1.8.1
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
Carl Quinn <ca...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |carl.quinn@gmail.com
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 49261] Copy task fails to overwrite readonly files
even with overwrite="true"
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=49261
--- Comment #2 from Stefan Bodewig <bo...@apache.org> 2010-05-07 10:34:56 EDT ---
my guess seems to be correct. I've added four testcases to Ant in svn revision
942805 - two of them disabled because they fail with Ant 1.8.x.
If I specify a dummy <filterset> Ant will happily overwrite the existing file,
without one - when Ant uses NIO - it won't but throw an exception instead.
Discussion about how to deal with it for Ant 1.8.2 will follow on the dev
list.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.