mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 02:13:00 +08:00
fix: cache path check
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user