fix(tz): attempt to fix timezone reading (#1810)

This commit is contained in:
Ellie Huxtable 2024-03-02 17:05:04 +00:00 committed by GitHub
parent f9fa441d60
commit 3d6b163546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -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));
}

View File

@ -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());