copyTo/moveTo overwrite

Alan Bateman Alan.Bateman at Sun.COM
Thu Jan 14 12:00:12 PST 2010


Salter, Thomas A wrote:
> When doing a copyTo or moveTo with different providers, it looks like 
> AbstractPath.copyToForeignTarget will overwrite the target file even 
> if REPLACE_EXISTING is not set.  It correctly deletes the target only 
> if REPLACE_EXISTING is set but then later in 
> copyRegularFileToForeignTarget calls newByteChannel with CREATE, so 
> any existing file is overwritten.  It should have used CREATE_NEW 
> instead of CREATE.
>  
You are right! When copying or moving a file to a location that is 
associated with some other provider then it shouldn't replace an 
existing file unless the REPLACE_EXISTING option is present. Thanks for 
finding this. Our of curiosity, did you find this by inspection or were 
you testing with your own provider? Our existing tests doesn't exercise 
this scenario (not yet anyway).

-Alan.


More information about the nio-dev mailing list