mirror of
https://github.com/veeso/termscp.git
synced 2025-12-06 17:15:35 -08:00
fix: don't update path breadcrumb if enter/scan dir failed (#203)
This commit is contained in:
committed by
GitHub
parent
295191b9eb
commit
ee28d34f29
@@ -11,7 +11,7 @@ use std::time::Instant;
|
|||||||
// Ext
|
// Ext
|
||||||
use bytesize::ByteSize;
|
use bytesize::ByteSize;
|
||||||
use remotefs::fs::{File, Metadata, ReadStream, UnixPex, Welcome, WriteStream};
|
use remotefs::fs::{File, Metadata, ReadStream, UnixPex, Welcome, WriteStream};
|
||||||
use remotefs::{RemoteError, RemoteErrorType};
|
use remotefs::{RemoteError, RemoteErrorType, RemoteResult};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use super::{FileTransferActivity, LogLevel};
|
use super::{FileTransferActivity, LogLevel};
|
||||||
@@ -115,9 +115,10 @@ impl FileTransferActivity {
|
|||||||
if let Ok(wrkdir) = self.client.pwd() {
|
if let Ok(wrkdir) = self.client.pwd() {
|
||||||
self.mount_blocking_wait("Loading remote directory...");
|
self.mount_blocking_wait("Loading remote directory...");
|
||||||
|
|
||||||
self.remote_scan(wrkdir.as_path());
|
if self.remote_scan(wrkdir.as_path()).is_ok() {
|
||||||
// Set wrkdir
|
// Set wrkdir
|
||||||
self.remote_mut().wrkdir = wrkdir;
|
self.remote_mut().wrkdir = wrkdir;
|
||||||
|
}
|
||||||
|
|
||||||
self.umount_wait();
|
self.umount_wait();
|
||||||
}
|
}
|
||||||
@@ -128,40 +129,47 @@ impl FileTransferActivity {
|
|||||||
self.mount_blocking_wait("Loading local directory...");
|
self.mount_blocking_wait("Loading local directory...");
|
||||||
|
|
||||||
let wrkdir: PathBuf = self.host.pwd();
|
let wrkdir: PathBuf = self.host.pwd();
|
||||||
self.local_scan(wrkdir.as_path());
|
|
||||||
self.local_mut().wrkdir = wrkdir;
|
if self.local_scan(wrkdir.as_path()).is_ok() {
|
||||||
|
self.local_mut().wrkdir = wrkdir;
|
||||||
|
}
|
||||||
|
|
||||||
self.umount_wait();
|
self.umount_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan current local directory
|
/// Scan current local directory
|
||||||
fn local_scan(&mut self, path: &Path) {
|
fn local_scan(&mut self, path: &Path) -> Result<(), HostError> {
|
||||||
match self.host.scan_dir(path) {
|
match self.host.scan_dir(path) {
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
// Set files and sort (sorting is implicit)
|
// Set files and sort (sorting is implicit)
|
||||||
self.local_mut().set_files(files);
|
self.local_mut().set_files(files);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not scan current directory: {err}"),
|
format!("Could not scan current directory: {err}"),
|
||||||
);
|
);
|
||||||
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Scan current remote directory
|
/// Scan current remote directory
|
||||||
fn remote_scan(&mut self, path: &Path) {
|
fn remote_scan(&mut self, path: &Path) -> RemoteResult<()> {
|
||||||
match self.client.list_dir(path) {
|
match self.client.list_dir(path) {
|
||||||
Ok(files) => {
|
Ok(files) => {
|
||||||
// Set files and sort (sorting is implicit)
|
// Set files and sort (sorting is implicit)
|
||||||
self.remote_mut().set_files(files);
|
self.remote_mut().set_files(files);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
self.log_and_alert(
|
self.log_and_alert(
|
||||||
LogLevel::Error,
|
LogLevel::Error,
|
||||||
format!("Could not scan current directory: {err}"),
|
format!("Could not scan current directory: {err}"),
|
||||||
);
|
);
|
||||||
|
Err(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user