[
https://issues.apache.org/jira/browse/SSHD-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17766857#comment-17766857
]
Lyor Goldstein edited comment on SSHD-1333 at 9/19/23 3:45 PM:
---------------------------------------------------------------
I understand that - my question was what would be the +semantics+ of the extra
supported options. Please note that any other option makes no sense. Please
note that we can only support what SCP protocol allows - adding a bunch of
options that have no meaning only muddle the API. If you need to call
{{FileSystemProvider#copy(Path, Path, CopyOption...)}} then do so after
translating the SCP options to {{CopyOption}}-s - if such translation is even
possible
{code:java|title=StandardCopyOption(s)}
package java.nio.file;
/**
* Defines the standard copy options.
*
* @since 1.7
*/
public enum StandardCopyOption implements CopyOption {
/**
* Replace an existing file if it exists.
*/
REPLACE_EXISTING,
/**
* Copy attributes to the new file.
*/
COPY_ATTRIBUTES,
/**
* Move the file as an atomic file system operation.
*/
ATOMIC_MOVE;
}
{code}
{code:java|title=SCP options}
public interface ScpClient extends SessionHolder<ClientSession>,
ClientSessionHolder {
enum Option {
Recursive("-r"),
PreserveAttributes("-p"),
TargetIsDirectory("-d"),
;
private final String optionValue;
Option(String optionValue) {
this.optionValue = optionValue;
}
/**
* @return The option value to use in the issued SCP command
*/
public String getOptionValue() {
return optionValue;
}
}
{code}
was (Author: lgoldstein):
I understand that - my question was what would be the +semantics+ of the extra
supported options. Please note that any other option makes no sense.
> Adding java.nio.file.CopyOption to SCP transfer methods
> -------------------------------------------------------
>
> Key: SSHD-1333
> URL: https://issues.apache.org/jira/browse/SSHD-1333
> Project: MINA SSHD
> Issue Type: New Feature
> Reporter: dgü
> Priority: Major
>
> Hello!
> remote-to-remote file transfer is available in SCP protocol. If I'm not
> wrong, it is not available in SFTP protocol.
> I'm trying to use the following code to handle remote-to-remote file transfer.
> {code:java}
> public class SSHDFileSystemProvider extends SftpFileSystemProvider {
> private final static String URI_SCHEME = "ssh";
>
> private final static boolean PRESERVE_ATTRIBUTES = true;
> @Override
> public String getScheme() {
> return URI_SCHEME;
> }
> @Override
> public void copy(Path sourcePath, Path targetPath, CopyOption... options)
> throws IOException {
> ClientSession sourceClientSession = ((SftpFileSystem)
> (sourcePath.getFileSystem())).getClientSession();
> ClientSession targetClientSession = ((SftpFileSystem)
> (targetPath.getFileSystem())).getClientSession();
> ScpRemote2RemoteTransferHelper helper = new
> ScpRemote2RemoteTransferHelper(sourceClientSession, targetClientSession);
> helper.transferFile(sourcePath.toString(), targetPath.toString(),
> PRESERVE_ATTRIBUTES);
> }
> }
> {code}
> _ScpRemote2RemoteTransferHelper.transferFile(String,String,boolean)_ accepts
> preserve attributes only as the copy option.
> My request:
> - is it possible to add java.nio.file.CopyOption to SCP transfer methods?
> Thanks in advance?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]