-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
*/ | ||
package com.xebialabs.overthere.spi; | ||
|
||
import com.xebialabs.overthere.CmdLine; | ||
import com.xebialabs.overthere.OperatingSystemFamily; | ||
import com.xebialabs.overthere.OverthereFile; | ||
import com.xebialabs.overthere.RuntimeIOException; | ||
import com.xebialabs.overthere.util.OverthereFileCopier; | ||
|
@@ -73,9 +75,37 @@ public final void copyTo(final OverthereFile dest) { | |
} | ||
|
||
protected void copyFrom(OverthereFile source) { | ||
OverthereFileCopier.copy(source, this); | ||
if (source.getConnection().equals(connection)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hierynomus
Author
Contributor
|
||
// Copying over same connection, let's do local | ||
localCopyFrom(source); | ||
} else { | ||
OverthereFileCopier.copy(source, this); | ||
} | ||
} | ||
|
||
/** | ||
* Copies this file or directory (recursively) to a (new) destination in the same connection. | ||
* @param source The source file or directory | ||
*/ | ||
protected void localCopyFrom(OverthereFile source) { | ||
OperatingSystemFamily hostOperatingSystem = source.getConnection().getHostOperatingSystem(); | ||
CmdLine cmdLine = new CmdLine(); | ||
switch (hostOperatingSystem) { | ||
case WINDOWS: | ||
cmdLine.addArgument("copy"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hierynomus
Author
Contributor
|
||
break; | ||
case UNIX: | ||
case ZOS: | ||
cmdLine.addArgument("cp"); | ||
This comment has been minimized.
Sorry, something went wrong.
vpartington
Contributor
|
||
break; | ||
} | ||
|
||
cmdLine.addArgument(source.getPath()).addArgument(getPath()); | ||
|
||
source.getConnection().execute(cmdLine); | ||
} | ||
|
||
|
||
/** | ||
* Subclasses MUST implement toString properly. | ||
*/ | ||
|
1 comment
on commit 6527560
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short and sweet! :-)
Is the
equals
on anOverthereConnection
guaranteed to betrue
when they are the same connection? Or could it also betrue
if it's a connection to the same host? Isn't==
safer here?