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
+10
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
+17 -18
View File
@@ -363,13 +363,28 @@ impl FileTransferActivity {
} }
} }
FsEntry::Directory(dir) => { FsEntry::Directory(dir) => {
// Create directory on remote // Check whether should create directory
if self.client.list_dir(remote_path.as_path()).is_err() {
match self.client.mkdir(remote_path.as_path()) { match self.client.mkdir(remote_path.as_path()) {
Ok(_) => { Ok(_) => {
self.log( self.log(
LogLevel::Info, LogLevel::Info,
format!("Created directory \"{}\"", remote_path.display()), format!("Created directory \"{}\"", remote_path.display()),
); );
}
Err(err) => {
self.log_and_alert(
LogLevel::Error,
format!(
"Failed to create directory \"{}\": {}",
remote_path.display(),
err
),
);
return;
}
}
}
// Get files in dir // Get files in dir
match self.host.scan_dir(dir.abs_path.as_path()) { match self.host.scan_dir(dir.abs_path.as_path()) {
Ok(entries) => { Ok(entries) => {
@@ -380,11 +395,7 @@ impl FileTransferActivity {
break; break;
} }
// Send entry; name is always None after first call // Send entry; name is always None after first call
self.filetransfer_send_recurse( self.filetransfer_send_recurse(&entry, remote_path.as_path(), None);
&entry,
remote_path.as_path(),
None,
);
} }
} }
Err(err) => { Err(err) => {
@@ -399,18 +410,6 @@ impl FileTransferActivity {
} }
} }
} }
Err(err) => {
self.log_and_alert(
LogLevel::Error,
format!(
"Failed to create directory \"{}\": {}",
remote_path.display(),
err
),
);
}
}
}
} }
// Scan dir on remote // Scan dir on remote
self.reload_remote_dir(); self.reload_remote_dir();