fuckit: no patch db locks (#1969)

* fuck it: no patchdb locks

* fix: Add the locking to the package during the backup. (#1979)

* fix: Add the locking to the package during the backup.

* fix: Lock for the uninstall of the package

* switch patch-db to next

Co-authored-by: J M <2364004+Blu-J@users.noreply.github.com>
This commit is contained in:
Aiden McClelland
2022-11-28 10:20:47 -07:00
parent a3a4fdd7fc
commit 2b0efb32c1
11 changed files with 35 additions and 28 deletions

View File

@@ -63,7 +63,7 @@ pub async fn list(#[context] ctx: RpcContext) -> Result<Vec<(PackageId, Version)
let mut hdl = ctx.db.handle();
let package_data = crate::db::DatabaseModel::new()
.package_data()
.get(&mut hdl, true)
.get(&mut hdl)
.await?;
Ok(package_data
@@ -601,6 +601,11 @@ pub async fn uninstall_dry(
pub async fn uninstall_impl(ctx: RpcContext, id: PackageId) -> Result<(), Error> {
let mut handle = ctx.db.handle();
let mut tx = handle.begin().await?;
crate::db::DatabaseModel::new()
.package_data()
.idx_model(&id)
.lock(&mut tx, LockType::Write)
.await?;
let mut pde = crate::db::DatabaseModel::new()
.package_data()
@@ -879,7 +884,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
.package_data()
.idx_model(dep)
.map::<_, Manifest>(|pde| pde.manifest())
.get(&mut ctx.db.handle(), false)
.get(&mut ctx.db.handle())
.await?
.into_owned()
{
@@ -1119,7 +1124,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
let mut deps = BTreeMap::new();
for package in crate::db::DatabaseModel::new()
.package_data()
.keys(&mut tx, true)
.keys(&mut tx)
.await?
{
// update dependency_info on dependents
@@ -1153,7 +1158,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin + Send + Sync>(
.await?
.installed()
.and_then(|i| i.current_dependencies().idx_model(pkg_id))
.get(&mut tx, true)
.get(&mut tx)
.await?
.to_owned()
{