This commit is contained in:
dr-frmr 2024-10-08 18:14:21 -04:00
parent b87cfbc674
commit 03b531ef64
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View File

@ -48,6 +48,9 @@ impl KvState {
pub async fn open_db(&mut self, package_id: PackageId, db: String) -> Result<(), KvError> { pub async fn open_db(&mut self, package_id: PackageId, db: String) -> Result<(), KvError> {
let key = (package_id.clone(), db.clone()); let key = (package_id.clone(), db.clone());
if self.open_kvs.contains_key(&key) { if self.open_kvs.contains_key(&key) {
let mut access_order = self.access_order.lock().await;
access_order.remove(&key);
access_order.push_back(key);
return Ok(()); return Ok(());
} }
@ -497,10 +500,11 @@ async fn check_caps(
.remove_db(request.package_id.clone(), request.db.clone()) .remove_db(request.package_id.clone(), request.db.clone())
.await; .await;
let _ = fs::remove_dir_all(format!( fs::remove_dir_all(format!(
"{}/{}/{}", "{}/{}/{}",
state.kv_path, request.package_id, request.db state.kv_path, request.package_id, request.db
)); ))
.await?;
Ok(()) Ok(())
} }

View File

@ -56,9 +56,9 @@ impl SqliteState {
pub async fn open_db(&mut self, package_id: PackageId, db: String) -> Result<(), SqliteError> { pub async fn open_db(&mut self, package_id: PackageId, db: String) -> Result<(), SqliteError> {
let key = (package_id.clone(), db.clone()); let key = (package_id.clone(), db.clone());
if self.open_dbs.contains_key(&key) { if self.open_dbs.contains_key(&key) {
// let mut access_order = self.access_order.lock().await; let mut access_order = self.access_order.lock().await;
// access_order.remove(&key); access_order.remove(&key);
// access_order.push_back(key); access_order.push_back(key);
return Ok(()); return Ok(());
} }
@ -515,10 +515,11 @@ async fn check_caps(
.remove_db(request.package_id.clone(), request.db.clone()) .remove_db(request.package_id.clone(), request.db.clone())
.await; .await;
let _ = fs::remove_dir_all(format!( fs::remove_dir_all(format!(
"{}/{}/{}", "{}/{}/{}",
state.sqlite_path, request.package_id, request.db state.sqlite_path, request.package_id, request.db
)); ))
.await?;
Ok(()) Ok(())
} }