fix issues with failed updates

This commit is contained in:
Aiden McClelland
2022-01-24 11:59:33 -07:00
committed by Keagan McClelland
parent 8a559b71fd
commit 3ab078a878
3 changed files with 21 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
use std::cmp::Ordering;
use std::path::Path;
use std::time::Duration;
use std::time::{Duration, Instant};
use divrem::DivRem;
use proptest_derive::Arbitrary;
@@ -37,6 +37,10 @@ impl SoundInterface {
}
})
.with_ctx(|_| (ErrorKind::SoundError, EXPORT_FILE.to_string_lossy()))?;
let instant = Instant::now();
while tokio::fs::metadata(&*PERIOD_FILE).await.is_err()
&& instant.elapsed() < Duration::from_secs(1)
{}
Ok(SoundInterface(Some(guard)))
}
#[instrument(skip(self))]

View File

@@ -1,5 +1,5 @@
use std::future::Future;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
@@ -10,7 +10,7 @@ use digest::Digest;
use emver::Version;
use futures::Stream;
use lazy_static::lazy_static;
use patch_db::{DbHandle, Revision};
use patch_db::{DbHandle, LockType, Revision};
use regex::Regex;
use reqwest::Url;
use rpc_toolkit::command;
@@ -25,7 +25,7 @@ use tracing::instrument;
use crate::context::RpcContext;
use crate::db::model::{ServerStatus, UpdateProgress};
use crate::db::util::WithRevision;
use crate::disk::mount::filesystem::label::Label;
use crate::disk::mount::filesystem::block_dev::BlockDev;
use crate::disk::mount::filesystem::FileSystem;
use crate::disk::mount::guard::TmpMountGuard;
use crate::disk::BOOT_RW_PATH;
@@ -98,11 +98,14 @@ impl WritableDrives {
Self::Blue => "blue",
}
}
fn block_dev(&self) -> PathBuf {
Path::new("/dev/disk/by-label").join(self.label())
fn block_dev(&self) -> &'static Path {
Path::new(match self {
Self::Green => "/dev/mmcblk0p3",
Self::Blue => "/dev/mmcblk0p4",
})
}
fn as_fs(&self) -> impl FileSystem {
Label::new(self.label())
BlockDev::new(self.block_dev())
}
}
@@ -132,6 +135,10 @@ async fn maybe_do_update(ctx: RpcContext) -> Result<Option<Arc<Revision>>, Error
.await
.with_kind(ErrorKind::Network)?
.version;
crate::db::DatabaseModel::new()
.server_info()
.lock(&mut db, LockType::Write)
.await?;
let current_version = crate::db::DatabaseModel::new()
.server_info()
.version()

View File

@@ -93,3 +93,6 @@ if ! [[ "$(cat $INPUT_HASH)" == "$(cat $OUTPUT_HASH)" ]]; then
fi
rm $INPUT_HASH $OUTPUT_HASH
echo "Verification Succeeded"
sudo e2label update.img red
echo "Image Relabeled to \"red\""