[
https://issues.apache.org/jira/browse/HADOOP-9507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13718809#comment-13718809
]
Chris Nauroth commented on HADOOP-9507:
---------------------------------------
I'm about to post some patches that resolve this and also some other cases.
I'm pasting a comment I originally entered on HADOOP-9767 that explains the
root cause:
POSIX rename semantics state that renaming a source directory to an existing
destination directory that is empty will act as a full replacement of that
existing destination. RawLocalFileSystem#rename calls Java's File#renameTo,
which provides these semantics on most platforms. On some platforms (notably
Windows), File#renameTo does not provide this behavior. This causes problems
for MapReduce and other downstream components like Hive, HCatalog, and Sqoop
that depend on the replacement behavior.
> LocalFileSystem rename() is broken in some cases when destination exists
> ------------------------------------------------------------------------
>
> Key: HADOOP-9507
> URL: https://issues.apache.org/jira/browse/HADOOP-9507
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Reporter: Mostafa Elhemali
> Assignee: Daryn Sharp
> Priority: Minor
> Attachments: HADOOP-9507.branch-1-win.patch
>
>
> The rename() method in RawLocalFileSystem uses FileUtil.copy() without
> realizing that FileUtil.copy() has a special behavior that if you're copying
> /foo to /bar and /bar exists and is a directory, it'll copy /foo inside /bar
> instead of overwriting it, which is not what rename() wants. So you end up
> with weird behaviors like in this repro:
> {code}
> c:
> cd \
> md Foo
> md Bar
> md Foo\X
> md Bar\X
> hadoop fs -mv file:///c:/Foo file:///c:/Bar
> {code}
> At the end of this, you would expect to find only Bar\X, but you instead find
> Bar\X\X.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira