2 Commits

Author SHA1 Message Date
Christian Visintin
4bebec369f fix: Issues with update checks (#363)
Some checks failed
Linux / build (push) Has been cancelled
MacOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Removed error popup message if failed to check for updates.
Prevent long timeouts when checking for updates if the network is down or the DNS is not working.

closes #354
2025-10-02 21:27:51 +02:00
Christian Visintin
05c8613279 fix: Report a message while calculating total size of files to transfer. (#362)
* fix: Report a message while calculating total size of files to transfer.

Currently, in case of huge transfers the app may look frozen while calculating the transfer size. We should at least report to the user we are actually doing something.

closes #361

* ci: windows runner
2025-10-02 20:58:26 +02:00
5 changed files with 54 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ env:
jobs: jobs:
build: build:
runs-on: windows-2019 runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@@ -49,6 +49,10 @@ Released on 20/09/2025
- [Issue 356](https://github.com/veeso/termscp/issues/356): Fixed SSH auth issue not trying with the password if any RSA key was found. - [Issue 356](https://github.com/veeso/termscp/issues/356): Fixed SSH auth issue not trying with the password if any RSA key was found.
- [Issue 334](https://github.com/veeso/termscp/issues/334): SMB support for MacOS with vendored build of libsmbclient. - [Issue 334](https://github.com/veeso/termscp/issues/334): SMB support for MacOS with vendored build of libsmbclient.
- [Issue 337](https://github.com/veeso/termscp/issues/337): Migrated to libssh.org on Linux and MacOS for better ssh agent support. - [Issue 337](https://github.com/veeso/termscp/issues/337): Migrated to libssh.org on Linux and MacOS for better ssh agent support.
- [Issue 361](https://github.com/veeso/termscp/issues/361): Report a message while calculating total size of files to transfer.
- [Issue 354](https://github.com/veeso/termscp/issues/354):
- Removed error popup message if failed to check for updates.
- Prevent long timeouts when checking for updates if the network is down or the DNS is not working.
## 0.18.0 ## 0.18.0

View File

@@ -2,6 +2,8 @@
//! //!
//! Automatic update module. This module is used to upgrade the current version of termscp to the latest available on Github //! Automatic update module. This module is used to upgrade the current version of termscp to the latest available on Github
use std::net::ToSocketAddrs as _;
use self_update::backends::github::Update as GithubUpdater; use self_update::backends::github::Update as GithubUpdater;
pub use self_update::errors::Error as UpdateError; pub use self_update::errors::Error as UpdateError;
use self_update::update::Release as UpdRelease; use self_update::update::Release as UpdRelease;
@@ -67,6 +69,9 @@ impl Update {
/// otherwise if no version is available, return None /// otherwise if no version is available, return None
/// In case of error returns Error with the error description /// In case of error returns Error with the error description
pub fn is_new_version_available() -> Result<Option<Release>, UpdateError> { pub fn is_new_version_available() -> Result<Option<Release>, UpdateError> {
// check if api.github.com is reachable before doing anything
Self::check_github_api_reachable()?;
info!("Checking whether a new version is available..."); info!("Checking whether a new version is available...");
GithubUpdater::configure() GithubUpdater::configure()
// Set default options // Set default options
@@ -83,6 +88,27 @@ impl Update {
.map(Self::check_version) .map(Self::check_version)
} }
/// Check if api.github.com is reachable
/// This is useful to avoid long timeouts when the network is down
/// or the DNS is not working
fn check_github_api_reachable() -> Result<(), UpdateError> {
let Some(socket_addr) = ("api.github.com", 443)
.to_socket_addrs()
.ok()
.and_then(|mut i| i.next())
else {
error!("Could not resolve api.github.com");
return Err(UpdateError::Network(
"Could not resolve api.github.com".into(),
));
};
// just try to open a connection to api.github.com with a timeout of 5 seconds with tcp
std::net::TcpStream::connect_timeout(&socket_addr, std::time::Duration::from_secs(5))
.map(|_| ())
.map_err(|e| UpdateError::Network(format!("Could not reach api.github.com: {e}")))
}
/// In case received version is newer than current one, version as Some is returned; otherwise None /// In case received version is newer than current one, version as Some is returned; otherwise None
fn check_version(r: Release) -> Option<Release> { fn check_version(r: Release) -> Option<Release> {
debug!("got version from GitHub: {}", r.version); debug!("got version from GitHub: {}", r.version);
@@ -212,4 +238,9 @@ mod test {
assert!(!Update::is_new_version_higher("0.9.9", "0.10.1")); assert!(!Update::is_new_version_higher("0.9.9", "0.10.1"));
assert!(!Update::is_new_version_higher("0.10.9", "0.11.0")); assert!(!Update::is_new_version_higher("0.10.9", "0.11.0"));
} }
#[test]
fn test_should_check_whether_github_api_is_reachable() {
assert!(Update::check_github_api_reachable().is_ok());
}
} }

View File

@@ -223,10 +223,7 @@ impl AuthActivity {
} }
Err(err) => { Err(err) => {
// Report error // Report error
error!("Failed to get latest version: {}", err); error!("Failed to get latest version: {err}",);
self.mount_error(
format!("Could not check for new updates: {err}").as_str(),
);
} }
} }
} else { } else {

View File

@@ -1260,7 +1260,10 @@ impl FileTransferActivity {
/// Get total size of transfer for host_bridgehost /// Get total size of transfer for host_bridgehost
fn get_total_transfer_size_host(&mut self, entry: &File) -> usize { fn get_total_transfer_size_host(&mut self, entry: &File) -> usize {
if entry.is_dir() { // mount message to tell we are calculating size
self.mount_blocking_wait("Calculating transfer size…");
let sz = if entry.is_dir() {
// List dir // List dir
match self.host_bridge.list_dir(entry.path()) { match self.host_bridge.list_dir(entry.path()) {
Ok(files) => files Ok(files) => files
@@ -1281,12 +1284,18 @@ impl FileTransferActivity {
} }
} else { } else {
entry.metadata.size as usize entry.metadata.size as usize
} };
self.umount_wait();
sz
} }
/// Get total size of transfer for remote host /// Get total size of transfer for remote host
fn get_total_transfer_size_remote(&mut self, entry: &File) -> usize { fn get_total_transfer_size_remote(&mut self, entry: &File) -> usize {
if entry.is_dir() { // mount message to tell we are calculating size
self.mount_blocking_wait("Calculating transfer size…");
let sz = if entry.is_dir() {
// List directory // List directory
match self.client.list_dir(entry.path()) { match self.client.list_dir(entry.path()) {
Ok(files) => files Ok(files) => files
@@ -1307,7 +1316,11 @@ impl FileTransferActivity {
} }
} else { } else {
entry.metadata.size as usize entry.metadata.size as usize
} };
self.umount_wait();
sz
} }
// file changed // file changed