hierynomus / hierynomus/sshj

SFTP Rename behavior

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

Description

Hi, I'm having two different weird behaviors using the rename method on the SFTPClient class.

### Scenario 1
Here's an existing file structure
```
folder1/
folder1/file1.csv

folder1/subfolder1/
folder1/subfolder1/file1.csv
```

Given this structure, the command I send is:
```
sftpClient.rename("folder1/file1.csv", "folder1/subfolder1/file1_1.csv");
```

The resulting structure is:
```
folder1/

folder1/subfolder1/
folder1/subfolder1/file1_1.csv
```

The file1.csv within subfolder1 was either deleted or renamed. This shouldn't happen. I expect this folder structure afterwards:
```
folder1/

folder1/subfolder1/
folder1/subfolder1/file1.csv
folder1/subfolder1/file1_1.csv
```

### Scenario 2
Sometimes when I rename the file, it appends its own random number to the end, which lives temporarily(sometimes) before going to its final name.

File Structure
```
folder1/
folder1/file1.csv

folder1/subfolder1/
```

Given this structure, the command I send is:
```
sftpClient.rename("folder1/file1.csv", "folder1/subfolder1/file1.csv");
```

The resulting structure is:
```
folder1/

folder1/subfolder1/
folder1/subfolder1/file1_382192394.csv
```

If I keep hitting refresh on Filezilla the name will SOMETIMES, but not always end up reverting back to file1.csv giving me the desired file structure of:
```
folder1/

folder1/subfolder1/
folder1/subfolder1/file1.csv
```

I'm not entirely sure where the problem is in these situations, whether with SSHJ or with the SFTP Server we're using. Here is some information on what I'm working with.

```
$ java -version

java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
```

We're using sshj v0.19.0
SFTP server info:
`Windows_NT version 5.0 (MOVEit DMZ FTP 8.3.0.0)`
it claims to be communicating using SFTPv3

Thanks in advance!

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.