Skip to content

Commit

Permalink
fix(tz): attempt to fix timezone reading (#1810)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie committed Mar 2, 2024
1 parent f9fa441 commit 3d6b163
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ impl FromStr for Timezone {
fn from_str(s: &str) -> Result<Self> {
// 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));
}

Expand Down
7 changes: 3 additions & 4 deletions atuin/src/command/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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());

Expand Down

0 comments on commit 3d6b163

Please sign in to comment.