mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-04 19:11:57 +08:00
c9bffc13b5
fix #13529 #### PR Dependency Tree * **PR #14481** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Mobile blob caching with file-backed storage for faster loads and reduced network usage * Blob decoding with lazy refresh on token-read failures for improved reliability * Full-text search/indexing exposed to mobile apps * Document sync APIs and peer clock management for robust cross-device sync * **Tests** * Added unit tests covering payload decoding, cache safety, and concurrency * **Dependencies** * Added an LRU cache dependency and a new mobile-shared package for shared mobile logic <!-- end of auto-generated comment: release notes by coderabbit.ai -->
101 lines
2.1 KiB
Rust
101 lines
2.1 KiB
Rust
use super::*;
|
|
|
|
#[uniffi::export(async_runtime = "tokio")]
|
|
impl DocStoragePool {
|
|
pub async fn crawl_doc_data(&self, universal_id: String, doc_id: String) -> Result<CrawlResult> {
|
|
let result = self
|
|
.inner
|
|
.get(universal_id.clone())
|
|
.await?
|
|
.crawl_doc_data(&doc_id)
|
|
.await?;
|
|
Ok(result.into())
|
|
}
|
|
|
|
pub async fn fts_add_document(
|
|
&self,
|
|
universal_id: String,
|
|
index_name: String,
|
|
doc_id: String,
|
|
text: String,
|
|
index: bool,
|
|
) -> Result<()> {
|
|
self
|
|
.inner
|
|
.get(universal_id)
|
|
.await?
|
|
.fts_add(&index_name, &doc_id, &text, index)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn fts_delete_document(&self, universal_id: String, index_name: String, doc_id: String) -> Result<()> {
|
|
self
|
|
.inner
|
|
.get(universal_id)
|
|
.await?
|
|
.fts_delete(&index_name, &doc_id)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn fts_get_document(
|
|
&self,
|
|
universal_id: String,
|
|
index_name: String,
|
|
doc_id: String,
|
|
) -> Result<Option<String>> {
|
|
Ok(
|
|
self
|
|
.inner
|
|
.get(universal_id)
|
|
.await?
|
|
.fts_get(&index_name, &doc_id)
|
|
.await?,
|
|
)
|
|
}
|
|
|
|
pub async fn fts_search(&self, universal_id: String, index_name: String, query: String) -> Result<Vec<SearchHit>> {
|
|
Ok(
|
|
self
|
|
.inner
|
|
.get(universal_id)
|
|
.await?
|
|
.fts_search(&index_name, &query)
|
|
.await?
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect(),
|
|
)
|
|
}
|
|
|
|
pub async fn fts_get_matches(
|
|
&self,
|
|
universal_id: String,
|
|
index_name: String,
|
|
doc_id: String,
|
|
query: String,
|
|
) -> Result<Vec<MatchRange>> {
|
|
Ok(
|
|
self
|
|
.inner
|
|
.get(universal_id)
|
|
.await?
|
|
.fts_get_matches(&index_name, &doc_id, &query)
|
|
.await?
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect(),
|
|
)
|
|
}
|
|
|
|
pub async fn fts_flush_index(&self, universal_id: String) -> Result<()> {
|
|
self.inner.get(universal_id).await?.flush_index().await?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn fts_index_version(&self) -> Result<u32> {
|
|
Ok(SqliteDocStorage::index_version())
|
|
}
|
|
}
|