Bug 2515 - Move Task deletes file when source and destination are identical.
Move Task deletes file when source and destination are identical.
Status: RESOLVED FIXED
Product: Ant
Classification: Unclassified
Component: Core tasks
unspecified
Other other
: P3 minor (vote)
: ---
Assigned To: Ant Notifications List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2001-07-09 07:49 UTC by Magesh Umasankar
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments
Checks to see if file names are identical, skips if they are. (900 bytes, patch)
2001-07-09 07:57 UTC, Magesh Umasankar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Magesh Umasankar 2001-07-09 07:49:13 UTC
The move task, as it is now, copies the source file to the destination and then 
deletes the source. 

Two issues:

1.  Copying is done even when the canonical file names are identical.  This 
mustn't be done.
2.  Deletion is performed unconditionally resulting in deletion of the 
destination file (which happens to be the same as the source, in this case).

In contrast, the copy task checks to see if the source and destination file 
names are the same and then skips copying it if they are.  

The Move task should either skip over the file quietly (as Ren does in Windows) 
or fail out saying the source and destination files are identical (as mv does 
in Unix)

I am marking it as a minor issue as I don't think users would be performing 
moves where the source and destination are the same.  But still, users will be  
users...

Sample:

Assuming file f1 is already in /export/home/mumasank, execution of the 
following task results in f1 being deleted.

   <target name="move2samefile">
      <move file="f1" tofile="../../home/mumasank/f1"/>
   </target>

Magesh
Comment 1 Magesh Umasankar 2001-07-09 07:57:32 UTC
Created attachment 299 [details]
Checks to see if file names are identical, skips if they are.
Comment 2 Stefan Bodewig 2001-08-06 23:57:33 UTC
fixed in nightly build 2001-08-08