mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-20 09:58:00 +02:00
fix: use spawn_blocking for file access during async context (#1936)
This commit is contained in:
parent
d434d4e8b7
commit
c41998e98a
@ -527,7 +527,13 @@ impl Settings {
|
|||||||
if !self.needs_update_check()? {
|
if !self.needs_update_check()? {
|
||||||
// Worst case, we don't want Atuin to fail to start because something funky is going on with
|
// Worst case, we don't want Atuin to fail to start because something funky is going on with
|
||||||
// version checking.
|
// version checking.
|
||||||
let version = match Settings::read_from_data_dir(LATEST_VERSION_FILENAME) {
|
let version = tokio::task::spawn_blocking(|| {
|
||||||
|
Settings::read_from_data_dir(LATEST_VERSION_FILENAME)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("file task panicked");
|
||||||
|
|
||||||
|
let version = match version {
|
||||||
Some(v) => Version::parse(&v).unwrap_or(current),
|
Some(v) => Version::parse(&v).unwrap_or(current),
|
||||||
None => current,
|
None => current,
|
||||||
};
|
};
|
||||||
@ -541,8 +547,14 @@ impl Settings {
|
|||||||
#[cfg(not(feature = "sync"))]
|
#[cfg(not(feature = "sync"))]
|
||||||
let latest = current;
|
let latest = current;
|
||||||
|
|
||||||
Settings::save_version_check_time()?;
|
let latest_encoded = latest.to_string();
|
||||||
Settings::save_to_data_dir(LATEST_VERSION_FILENAME, latest.to_string().as_str())?;
|
tokio::task::spawn_blocking(move || {
|
||||||
|
Settings::save_version_check_time()?;
|
||||||
|
Settings::save_to_data_dir(LATEST_VERSION_FILENAME, &latest_encoded)?;
|
||||||
|
Ok::<(), eyre::Report>(())
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("file task panicked")?;
|
||||||
|
|
||||||
Ok(latest)
|
Ok(latest)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user