When uploading a directory, create directory only if it doesn't exist

This commit is contained in:
veeso
2021-08-10 22:17:36 +02:00
parent 6cfac57162
commit 1757eb5bec
2 changed files with 44 additions and 35 deletions

View File

@@ -1,6 +1,7 @@
# Changelog # Changelog
- [Changelog](#changelog) - [Changelog](#changelog)
- [0.7.0](#070)
- [0.6.0](#060) - [0.6.0](#060)
- [0.5.1](#051) - [0.5.1](#051)
- [0.5.0](#050) - [0.5.0](#050)
@@ -19,6 +20,15 @@
--- ---
## 0.7.0
Released on ??
> 🍁 Autumn update 2021 🍇
- Bugfix:
- Fixed [Issue 58](https://github.com/veeso/termscp/issues/58):When uploading a directory, create directory only if it doesn't exist
## 0.6.0 ## 0.6.0
Released on 23/07/2021 Released on 23/07/2021

View File

@@ -363,48 +363,47 @@ impl FileTransferActivity {
} }
} }
FsEntry::Directory(dir) => { FsEntry::Directory(dir) => {
// Create directory on remote // Check whether should create directory
match self.client.mkdir(remote_path.as_path()) { if self.client.list_dir(remote_path.as_path()).is_err() {
Ok(_) => { match self.client.mkdir(remote_path.as_path()) {
self.log( Ok(_) => {
LogLevel::Info, self.log(
format!("Created directory \"{}\"", remote_path.display()), LogLevel::Info,
); format!("Created directory \"{}\"", remote_path.display()),
// Get files in dir );
match self.host.scan_dir(dir.abs_path.as_path()) { }
Ok(entries) => { Err(err) => {
// Iterate over files self.log_and_alert(
for entry in entries.iter() { LogLevel::Error,
// If aborted; break format!(
if self.transfer.aborted() { "Failed to create directory \"{}\": {}",
break; remote_path.display(),
} err
// Send entry; name is always None after first call ),
self.filetransfer_send_recurse( );
&entry, return;
remote_path.as_path(), }
None, }
); }
} // Get files in dir
} match self.host.scan_dir(dir.abs_path.as_path()) {
Err(err) => { Ok(entries) => {
self.log_and_alert( // Iterate over files
LogLevel::Error, for entry in entries.iter() {
format!( // If aborted; break
"Could not scan directory \"{}\": {}", if self.transfer.aborted() {
dir.abs_path.display(), break;
err
),
);
} }
// Send entry; name is always None after first call
self.filetransfer_send_recurse(&entry, remote_path.as_path(), None);
} }
} }
Err(err) => { Err(err) => {
self.log_and_alert( self.log_and_alert(
LogLevel::Error, LogLevel::Error,
format!( format!(
"Failed to create directory \"{}\": {}", "Could not scan directory \"{}\": {}",
remote_path.display(), dir.abs_path.display(),
err err
), ),
); );