update patch-db

This commit is contained in:
Aiden McClelland
2021-12-16 13:53:43 -07:00
committed by Aiden McClelland
parent 09dacfdfeb
commit 2384e60d0f
9 changed files with 53 additions and 10 deletions

View File

@@ -310,7 +310,7 @@ async fn perform_backup<Db: DbHandle>(
.synchronize()
.await;
installed_model.lock(&mut db, LockType::Write).await;
installed_model.lock(&mut db, LockType::Write).await?;
let guard = backup_guard.mount_package_backup(&package_id).await?;
let res = manifest

View File

@@ -304,7 +304,7 @@ pub fn configure_rec<'a, Db: DbHandle>(
crate::db::DatabaseModel::new()
.package_data()
.lock(db, LockType::Write)
.await;
.await?;
// fetch data from db
let pkg_model = crate::db::DatabaseModel::new()
.package_data()

View File

@@ -820,7 +820,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
crate::db::DatabaseModel::new()
.package_data()
.lock(&mut tx, LockType::Write)
.await;
.await?;
tracing::info!("Install {}@{}: Creating volumes", pkg_id, version);
manifest.volumes.install(ctx, pkg_id, version).await?;

View File

@@ -26,8 +26,8 @@ pub async fn dry(
let mut breakages = BTreeMap::new();
crate::db::DatabaseModel::new()
.package_data()
.lock(&mut tx, LockType::DeepRead)
.await;
.lock(&mut tx, LockType::Read)
.await?;
for dependent in crate::db::DatabaseModel::new()
.package_data()
.idx_model(&id)

View File

@@ -37,7 +37,7 @@ pub async fn list(
let model = crate::db::DatabaseModel::new()
.server_info()
.unread_notification_count();
model.lock(&mut handle, LockType::Write).await;
model.lock(&mut handle, LockType::Write).await?;
let records = sqlx::query!(
"SELECT id, package_id, created_at, code, level, title, message, data FROM notifications ORDER BY id DESC LIMIT ?",
limit

View File

@@ -78,7 +78,7 @@ pub async fn shutdown(#[context] ctx: RpcContext) -> Result<(), Error> {
let mut db = ctx.db.handle();
crate::db::DatabaseModel::new()
.lock(&mut db, LockType::Write)
.await;
.await?;
ctx.shutdown
.send(Some(Shutdown {
datadir: ctx.datadir.clone(),
@@ -96,7 +96,7 @@ pub async fn restart(#[context] ctx: RpcContext) -> Result<(), Error> {
let mut db = ctx.db.handle();
crate::db::DatabaseModel::new()
.lock(&mut db, LockType::Write)
.await;
.await?;
ctx.shutdown
.send(Some(Shutdown {
datadir: ctx.datadir.clone(),

View File

@@ -107,7 +107,7 @@ pub async fn init<Db: DbHandle>(db: &mut Db) -> Result<(), Error> {
let ptr: JsonPointer = "/server-info/version"
.parse()
.with_kind(crate::ErrorKind::Database)?;
db.lock(ptr.clone(), LockType::Write).await;
db.lock(ptr.clone(), LockType::Write).await?;
let version: Version = db.get(&ptr).await?;
match version {
Version::V0_3_0(v) => v.0.migrate_to(&Current::new(), db).await?,