From 3d6b16354697e6036a57819d79f2f6084392938a Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sat, 2 Mar 2024 17:05:04 +0000 Subject: fix(tz): attempt to fix timezone reading (#1810) --- atuin-client/src/settings.rs | 6 +++++- atuin/src/command/client.rs | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index a71091e2..3b34381c 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -151,7 +151,11 @@ impl FromStr for Timezone { fn from_str(s: &str) -> Result { // local timezone if matches!(s.to_lowercase().as_str(), "l" | "local") { - let offset = UtcOffset::current_local_offset()?; + // There have been some timezone issues, related to errors fetching it on some + // platforms + // Rather than fail to start, fallback to UTC. The user should still be able to specify + // their timezone manually in the config file. + let offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC); return Ok(Self(offset)); } diff --git a/atuin/src/command/client.rs b/atuin/src/command/client.rs index 6aacf422..ec2a03fb 100644 --- a/atuin/src/command/client.rs +++ b/atuin/src/command/client.rs @@ -74,14 +74,15 @@ impl Cmd { .build() .unwrap(); - let res = runtime.block_on(self.run_inner()); + let settings = Settings::new().wrap_err("could not load client settings")?; + let res = runtime.block_on(self.run_inner(settings)); runtime.shutdown_timeout(std::time::Duration::from_millis(50)); res } - async fn run_inner(self) -> Result<()> { + async fn run_inner(self, mut settings: Settings) -> Result<()> { Builder::new() .filter_level(log::LevelFilter::Off) .filter_module("sqlx_sqlite::regexp", log::LevelFilter::Off) @@ -90,8 +91,6 @@ impl Cmd { tracing::trace!(command = ?self, "client command"); - let mut settings = Settings::new().wrap_err("could not load client settings")?; - let db_path = PathBuf::from(settings.db_path.as_str()); let record_store_path = PathBuf::from(settings.record_store_path.as_str()); -- cgit v1.2.3