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

43
appmgr/Cargo.lock generated
View File

@@ -236,6 +236,15 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitmaps"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "bitvec" name = "bitvec"
version = "0.19.5" version = "0.19.5"
@@ -1437,6 +1446,20 @@ dependencies = [
"unicode-normalization", "unicode-normalization",
] ]
[[package]]
name = "imbl"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "543682c9082b25e63d03b5acbd65ad111fd49dd93e70843e5175db4ff81d606b"
dependencies = [
"bitmaps",
"rand_core 0.6.3",
"rand_xoshiro",
"sized-chunks",
"typenum",
"version_check",
]
[[package]] [[package]]
name = "indenter" name = "indenter"
version = "0.3.3" version = "0.3.3"
@@ -2076,6 +2099,7 @@ dependencies = [
"async-trait", "async-trait",
"fd-lock-rs", "fd-lock-rs",
"futures", "futures",
"imbl",
"json-patch", "json-patch",
"json-ptr", "json-ptr",
"lazy_static", "lazy_static",
@@ -2468,6 +2492,15 @@ dependencies = [
"rand_core 0.6.3", "rand_core 0.6.3",
] ]
[[package]]
name = "rand_xoshiro"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa"
dependencies = [
"rand_core 0.6.3",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.1.57" version = "0.1.57"
@@ -3012,6 +3045,16 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b"
[[package]]
name = "sized-chunks"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e"
dependencies = [
"bitmaps",
"typenum",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.4" version = "0.4.4"

View File

@@ -310,7 +310,7 @@ async fn perform_backup<Db: DbHandle>(
.synchronize() .synchronize()
.await; .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 guard = backup_guard.mount_package_backup(&package_id).await?;
let res = manifest let res = manifest

View File

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

View File

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

View File

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

View File

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

View File

@@ -78,7 +78,7 @@ pub async fn shutdown(#[context] ctx: RpcContext) -> Result<(), Error> {
let mut db = ctx.db.handle(); let mut db = ctx.db.handle();
crate::db::DatabaseModel::new() crate::db::DatabaseModel::new()
.lock(&mut db, LockType::Write) .lock(&mut db, LockType::Write)
.await; .await?;
ctx.shutdown ctx.shutdown
.send(Some(Shutdown { .send(Some(Shutdown {
datadir: ctx.datadir.clone(), datadir: ctx.datadir.clone(),
@@ -96,7 +96,7 @@ pub async fn restart(#[context] ctx: RpcContext) -> Result<(), Error> {
let mut db = ctx.db.handle(); let mut db = ctx.db.handle();
crate::db::DatabaseModel::new() crate::db::DatabaseModel::new()
.lock(&mut db, LockType::Write) .lock(&mut db, LockType::Write)
.await; .await?;
ctx.shutdown ctx.shutdown
.send(Some(Shutdown { .send(Some(Shutdown {
datadir: ctx.datadir.clone(), 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" let ptr: JsonPointer = "/server-info/version"
.parse() .parse()
.with_kind(crate::ErrorKind::Database)?; .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?; let version: Version = db.get(&ptr).await?;
match version { match version {
Version::V0_3_0(v) => v.0.migrate_to(&Current::new(), db).await?, Version::V0_3_0(v) => v.0.migrate_to(&Current::new(), db).await?,