fix: cache path check

This commit is contained in:
DarkSky
2026-02-20 00:58:04 +08:00
parent 7a8db38891
commit 849699e93f
16 changed files with 203 additions and 67 deletions

View File

@@ -55,16 +55,20 @@ impl SqliteDocStoragePool {
pub async fn disconnect(&self, universal_id: String) -> Result<()> {
let storage = {
let mut lock = self.inner.write().await;
if let Entry::Occupied(entry) = lock.entry(universal_id) {
Some(entry.remove())
} else {
None
}
lock.remove(&universal_id)
};
if let Some(storage) = storage {
storage.close().await;
let Some(storage) = storage else {
return Ok(());
};
// Prevent shutting down the shared storage while requests still hold refs.
if Arc::strong_count(&storage) > 1 {
let mut lock = self.inner.write().await;
lock.insert(universal_id, storage);
return Err(Error::InvalidOperation);
}
storage.close().await;
Ok(())
}
}

View File

@@ -41,7 +41,7 @@
"build": "napi build -p affine_native --platform --release",
"build:debug": "napi build -p affine_native --platform",
"universal": "napi universal",
"test": "ava",
"test": "ava --no-worker-threads --concurrency=2",
"version": "napi version"
},
"version": "0.26.1"