mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 01:26:04 -08:00
the logic of selecting files has been extended! From now on selecting file will put the files into a transfer queue, which is shown on the bottom panel. When a file is selected the file is added to the queue with a destination path, which is the **current other explorer path at the moment of selection. It is possible to navigate to the transfer queue by using `P` and pressing `ENTER` on a file will remove it from the transfer queue.Other commands will work as well on the transfer queue, like `COPY`, `MOVE`, `DELETE`, `RENAME`. closes #132
96 lines
2.9 KiB
Rust
96 lines
2.9 KiB
Rust
//! ## FileTransferActivity
|
|
//!
|
|
//! `filetransfer_activiy` is the module which implements the Filetransfer activity, which is the main activity afterall
|
|
|
|
// locals
|
|
use remotefs::File;
|
|
|
|
use super::{FileTransferActivity, LogLevel, SelectedFile};
|
|
|
|
impl FileTransferActivity {
|
|
pub(crate) fn action_local_delete(&mut self) {
|
|
match self.get_local_selected_entries() {
|
|
SelectedFile::One(entry) => {
|
|
// Delete file
|
|
self.local_remove_file(&entry);
|
|
}
|
|
SelectedFile::Many(entries) => {
|
|
// Iter files
|
|
for (entry, _) in entries.iter() {
|
|
// Delete file
|
|
self.local_remove_file(entry);
|
|
}
|
|
|
|
// clear selection
|
|
self.host_bridge_mut().clear_queue();
|
|
self.reload_host_bridge_filelist();
|
|
}
|
|
SelectedFile::None => {}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn action_remote_delete(&mut self) {
|
|
match self.get_remote_selected_entries() {
|
|
SelectedFile::One(entry) => {
|
|
// Delete file
|
|
self.remote_remove_file(&entry);
|
|
}
|
|
SelectedFile::Many(entries) => {
|
|
// Iter files
|
|
for (entry, _) in entries.iter() {
|
|
// Delete file
|
|
self.remote_remove_file(entry);
|
|
}
|
|
|
|
// clear selection
|
|
self.remote_mut().clear_queue();
|
|
self.reload_remote_filelist();
|
|
}
|
|
SelectedFile::None => {}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn local_remove_file(&mut self, entry: &File) {
|
|
match self.host_bridge.remove(entry) {
|
|
Ok(_) => {
|
|
// Log
|
|
self.log(
|
|
LogLevel::Info,
|
|
format!("Removed file \"{}\"", entry.path().display()),
|
|
);
|
|
}
|
|
Err(err) => {
|
|
self.log_and_alert(
|
|
LogLevel::Error,
|
|
format!(
|
|
"Could not delete file \"{}\": {}",
|
|
entry.path().display(),
|
|
err
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn remote_remove_file(&mut self, entry: &File) {
|
|
match self.client.remove_dir_all(entry.path()) {
|
|
Ok(_) => {
|
|
self.log(
|
|
LogLevel::Info,
|
|
format!("Removed file \"{}\"", entry.path().display()),
|
|
);
|
|
}
|
|
Err(err) => {
|
|
self.log_and_alert(
|
|
LogLevel::Error,
|
|
format!(
|
|
"Could not delete file \"{}\": {}",
|
|
entry.path().display(),
|
|
err
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|