sync data to fs before shutdown (#1690)

This commit is contained in:
Aiden McClelland
2022-07-25 15:23:40 -06:00
committed by GitHub
parent 0dd6d3a500
commit a7cd1e0ce6
3 changed files with 11 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ use embassy::shutdown::Shutdown;
use embassy::sound::CHIME;
use embassy::util::logger::EmbassyLogger;
use embassy::util::Invoke;
use embassy::{Error, ResultExt};
use embassy::{Error, ErrorKind, ResultExt};
use http::StatusCode;
use rpc_toolkit::rpc_server;
use tokio::process::Command;
@@ -131,6 +131,7 @@ async fn run_script_if_exists<P: AsRef<Path>>(path: P) {
async fn inner_main(cfg_path: Option<&str>) -> Result<Option<Shutdown>, Error> {
if tokio::fs::metadata(STANDBY_MODE_PATH).await.is_ok() {
tokio::fs::remove_file(STANDBY_MODE_PATH).await?;
Command::new("sync").invoke(ErrorKind::Filesystem).await?;
embassy::sound::SHUTDOWN.play().await?;
futures::future::pending::<()>().await;
}