HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal shell commands. Contributed by Uma Maheswara Rao G
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1144858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ec9b178c6
commit
e8eed98feb
|
@ -248,6 +248,9 @@ Trunk (unreleased changes)
|
||||||
to Data(In,Out)putBuffer for byte[]. Merge from yahoo-merge branch,
|
to Data(In,Out)putBuffer for byte[]. Merge from yahoo-merge branch,
|
||||||
-r 1079163. Fix missing Apache license headers. (Chris Douglas via mattf)
|
-r 1079163. Fix missing Apache license headers. (Chris Douglas via mattf)
|
||||||
|
|
||||||
|
HADOOP-7361. Provide an option, -overwrite/-f, in put and copyFromLocal
|
||||||
|
shell commands. (Uma Maheswara Rao G via szetszwo)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole
|
HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole
|
||||||
|
|
|
@ -38,7 +38,12 @@ abstract class CommandWithDestination extends FsCommand {
|
||||||
protected PathData dst;
|
protected PathData dst;
|
||||||
protected boolean overwrite = false;
|
protected boolean overwrite = false;
|
||||||
|
|
||||||
// TODO: commands should implement a -f to enable this
|
/**
|
||||||
|
*
|
||||||
|
* This method is used to enable the force(-f) option while copying the files.
|
||||||
|
*
|
||||||
|
* @param flag true/false
|
||||||
|
*/
|
||||||
protected void setOverwrite(boolean flag) {
|
protected void setOverwrite(boolean flag) {
|
||||||
overwrite = flag;
|
overwrite = flag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,15 +94,16 @@ class CopyCommands {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processOptions(LinkedList<String> args) throws IOException {
|
protected void processOptions(LinkedList<String> args) throws IOException {
|
||||||
CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE);
|
CommandFormat cf = new CommandFormat(2, Integer.MAX_VALUE, "f");
|
||||||
cf.parse(args);
|
cf.parse(args);
|
||||||
|
setOverwrite(cf.getOpt("f"));
|
||||||
getRemoteDestination(args);
|
getRemoteDestination(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processPath(PathData src, PathData target)
|
protected void processPath(PathData src, PathData target)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (!FileUtil.copy(src.fs, src.path, target.fs, target.path, false, getConf())) {
|
if (!FileUtil.copy(src.fs, src.path, target.fs, target.path, false, overwrite, getConf())) {
|
||||||
// we have no idea what the error is... FileUtils masks it and in
|
// we have no idea what the error is... FileUtils masks it and in
|
||||||
// some cases won't even report an error
|
// some cases won't even report an error
|
||||||
throw new PathIOException(src.toString());
|
throw new PathIOException(src.toString());
|
||||||
|
@ -216,8 +217,9 @@ class CopyCommands {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processOptions(LinkedList<String> args) throws IOException {
|
protected void processOptions(LinkedList<String> args) throws IOException {
|
||||||
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE);
|
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE, "f");
|
||||||
cf.parse(args);
|
cf.parse(args);
|
||||||
|
setOverwrite(cf.getOpt("f"));
|
||||||
getRemoteDestination(args);
|
getRemoteDestination(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +248,7 @@ class CopyCommands {
|
||||||
@Override
|
@Override
|
||||||
protected void processPath(PathData src, PathData target)
|
protected void processPath(PathData src, PathData target)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
target.fs.copyFromLocalFile(false, false, src.path, target.path);
|
target.fs.copyFromLocalFile(false, overwrite, src.path, target.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copies from stdin to the destination file. */
|
/** Copies from stdin to the destination file. */
|
||||||
|
|
Loading…
Reference in New Issue