This commit is contained in:
ChristianVisintin
2020-11-30 14:02:09 +01:00
parent 3e9d77cfac
commit 7960776abb

View File

@@ -300,7 +300,12 @@ impl FileTransferActivity {
/// Send fs entry to remote. /// Send fs entry to remote.
/// If dst_name is Some, entry will be saved with a different name. /// If dst_name is Some, entry will be saved with a different name.
/// If entry is a directory, this applies to directory only /// If entry is a directory, this applies to directory only
fn filetransfer_send(&mut self, entry: &FsEntry, curr_remote_path: &Path, dst_name: Option<String>) { fn filetransfer_send(
&mut self,
entry: &FsEntry,
curr_remote_path: &Path,
dst_name: Option<String>,
) {
// Write popup // Write popup
let file_name: String = match entry { let file_name: String = match entry {
FsEntry::Directory(dir) => dir.name.clone(), FsEntry::Directory(dir) => dir.name.clone(),
@@ -818,12 +823,14 @@ impl FileTransferActivity {
// NOTE: Do you want my opinion about that issue? It's a bs and doesn't make any sense. // NOTE: Do you want my opinion about that issue? It's a bs and doesn't make any sense.
let popup: Option<PopupType> = match &self.input_mode { let popup: Option<PopupType> = match &self.input_mode {
InputMode::Popup(ptype) => Some(ptype.clone()), InputMode::Popup(ptype) => Some(ptype.clone()),
_ => None _ => None,
}; };
match &self.input_mode { match &self.input_mode {
InputMode::Explorer => self.handle_input_event_mode_explorer(ev), InputMode::Explorer => self.handle_input_event_mode_explorer(ev),
InputMode::Popup(_) => if let Some(popup) = popup { InputMode::Popup(_) => {
self.handle_input_event_mode_popup(ev, popup); if let Some(popup) = popup {
self.handle_input_event_mode_popup(ev, popup);
}
} }
} }
} }
@@ -967,8 +974,12 @@ impl FileTransferActivity {
let wrkdir: PathBuf = match self.client.pwd() { let wrkdir: PathBuf = match self.client.pwd() {
Ok(p) => p, Ok(p) => p,
Err(err) => { Err(err) => {
self.log(LogLevel::Error, format!("Could not get current remote path: {}", err).as_ref()); self.log(
return LogLevel::Error,
format!("Could not get current remote path: {}", err)
.as_ref(),
);
return;
} }
}; };
// Get files // Get files
@@ -1154,19 +1165,22 @@ impl FileTransferActivity {
self.input_mode = self.create_quit_popup(); self.input_mode = self.create_quit_popup();
} }
KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab KeyCode::Tab => self.switch_input_field(), // <TAB> switch tab
KeyCode::Down => { // NOTE: Twisted logic KeyCode::Down => {
// NOTE: Twisted logic
// Decrease log index // Decrease log index
if self.log_index > 0 { if self.log_index > 0 {
self.log_index = self.log_index - 1; self.log_index = self.log_index - 1;
} }
} }
KeyCode::Up => { // NOTE: Twisted logic KeyCode::Up => {
// NOTE: Twisted logic
// Increase log index // Increase log index
if self.log_index + 1 < self.log_records.len() { if self.log_index + 1 < self.log_records.len() {
self.log_index = self.log_index + 1; self.log_index = self.log_index + 1;
} }
} }
KeyCode::PageDown => { // NOTE: Twisted logic KeyCode::PageDown => {
// NOTE: Twisted logic
// Fast decreasing of log index // Fast decreasing of log index
if self.log_index >= records_block { if self.log_index >= records_block {
self.log_index = self.log_index - records_block; // Decrease by `records_block` if possible self.log_index = self.log_index - records_block; // Decrease by `records_block` if possible
@@ -1174,7 +1188,8 @@ impl FileTransferActivity {
self.log_index = 0; // Set to 0 otherwise self.log_index = 0; // Set to 0 otherwise
} }
} }
KeyCode::PageUp => { // NOTE: Twisted logic KeyCode::PageUp => {
// NOTE: Twisted logic
// Fast increasing of log index // Fast increasing of log index
if self.log_index + records_block >= self.log_records.len() { if self.log_index + records_block >= self.log_records.len() {
// If overflows, set to size // If overflows, set to size
@@ -1373,27 +1388,28 @@ impl FileTransferActivity {
let mut d: PathBuf = self.context.as_ref().unwrap().local.pwd(); let mut d: PathBuf = self.context.as_ref().unwrap().local.pwd();
d.push(dir_path); d.push(dir_path);
d d
}, }
false => dir_path false => dir_path,
}; };
self.local_changedir(abs_dir_path.as_path(), true); self.local_changedir(abs_dir_path.as_path(), true);
} }
FileExplorerTab::Remote => { FileExplorerTab::Remote => {
// If path is relative, concat pwd // If path is relative, concat pwd
let abs_dir_path: PathBuf = match dir_path.is_relative() { let abs_dir_path: PathBuf = match dir_path.is_relative() {
true => { true => match self.client.pwd() {
match self.client.pwd() { Ok(mut wkrdir) => {
Ok(mut wkrdir) => { wkrdir.push(dir_path);
wkrdir.push(dir_path); wkrdir
wkrdir }
} Err(err) => {
Err(err) => { self.input_mode = InputMode::Popup(PopupType::Alert(
self.input_mode = InputMode::Popup(PopupType::Alert(Color::Red, format!("Could not retrieve current directory: {}", err))); Color::Red,
return; format!("Could not retrieve current directory: {}", err),
} ));
return;
} }
}, },
false => dir_path false => dir_path,
}; };
self.remote_changedir(abs_dir_path.as_path(), true); self.remote_changedir(abs_dir_path.as_path(), true);
} }
@@ -1656,8 +1672,11 @@ impl FileTransferActivity {
let wrkdir: PathBuf = match self.client.pwd() { let wrkdir: PathBuf = match self.client.pwd() {
Ok(p) => p, Ok(p) => p,
Err(err) => { Err(err) => {
self.log(LogLevel::Error, format!("Could not get current remote path: {}", err).as_ref()); self.log(
return LogLevel::Error,
format!("Could not get current remote path: {}", err).as_ref(),
);
return;
} }
}; };
let files: Vec<FsEntry> = self.local.files.clone(); let files: Vec<FsEntry> = self.local.files.clone();
@@ -1958,7 +1977,8 @@ impl FileTransferActivity {
0 => String::from("--:--"), // NOTE: would divide by 0 :D 0 => String::from("--:--"), // NOTE: would divide by 0 :D
_ => { _ => {
let elapsed_secs: u64 = self.transfer_started.elapsed().as_secs(); let elapsed_secs: u64 = self.transfer_started.elapsed().as_secs();
let eta: u64 = ((elapsed_secs * 100) / (self.transfer_progress as u64)) - elapsed_secs; let eta: u64 =
((elapsed_secs * 100) / (self.transfer_progress as u64)) - elapsed_secs;
format!("{:0width$}:{:0width$}", (eta / 60), (eta % 60), width = 2) format!("{:0width$}:{:0width$}", (eta / 60), (eta % 60), width = 2)
} }
}; };