hierynomus / hierynomus/sshj

Can't inambiguously mark SFTP upload destination as a file or dir

Open
#774 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.7k
Forks
620
Avg merge
3d 23h
Merged PRs (30d)
11

Description

I'm calling `StatefulSFTPClient.put(LocalSourceFile source, String dest)`
and when the dest exists and is a directory, `dest + "/" + source.getName()` is used. However, if the dest does not exist on the server a regular file with that path will be created there. I would expect the transfer to fail with "no such file or directory".

If I pass the full destination file path as the parameter and the destination already exists and is a directory, e.g. `/test.dat/` then the remote file will be created `/test.dat/test.dat`

The current behavior is fine for command line utils, but is not for a library.

I suggest adding a check to the beginning of `SFTPFileTransfer.Uploader.isDirectory(final String remote)` that if `remote` ends with "/", consider it a directory.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.