aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/daemon/src/api')
-rw-r--r--crates/daemon/src/api/control.rs8
-rw-r--r--crates/daemon/src/api/history.rs23
2 files changed, 9 insertions, 22 deletions
diff --git a/crates/daemon/src/api/control.rs b/crates/daemon/src/api/control.rs
index a9d9cff3..94fb7ce9 100644
--- a/crates/daemon/src/api/control.rs
+++ b/crates/daemon/src/api/control.rs
@@ -95,7 +95,9 @@ impl Control for ControlService {
&self,
_request: Request<ForceSyncRequest>,
) -> Result<Response<ForceSyncReply>, Status> {
- let reply = ForceSyncReply { accepted: false };
+ let reply = ForceSyncReply { accepted: true };
+
+ self.handle.emit(DaemonEvent::ForceSync);
Ok(Response::new(reply))
}
@@ -212,7 +214,6 @@ async fn do_sync_tick(
Err(e) => {
tracing::error!("sync tick failed with {e}");
- // Emit failure event
handle.emit(DaemonEvent::SyncFailed {
error: e.to_string(),
});
@@ -251,9 +252,6 @@ async fn do_sync_tick(
tracing::error!("failed to build history from downloaded records: {e}");
}
- // Emit the records added event (for search indexing)
- handle.emit(DaemonEvent::RecordsAdded(downloaded_records.clone()));
-
// Emit sync completed event
handle.emit(DaemonEvent::SyncCompleted {
uploaded: uploaded_count as usize,
diff --git a/crates/daemon/src/api/history.rs b/crates/daemon/src/api/history.rs
index bcd2ee5a..d024ea92 100644
--- a/crates/daemon/src/api/history.rs
+++ b/crates/daemon/src/api/history.rs
@@ -8,11 +8,7 @@ use tonic::{Request, Response, Status};
use tracing::{Level, instrument};
use crate::{
- aclient::{
- database::{ClientSqlite, current_context},
- history::store::HistoryStore,
- settings::Settings,
- },
+ aclient::{history::store::HistoryStore, settings::Settings},
daemon::DaemonHandle,
events::DaemonEvent,
};
@@ -41,12 +37,10 @@ pub(crate) struct HistoryService {
/// History store for pushing records
history_store: HistoryStore,
-
- history_db: ClientSqlite,
}
impl HistoryService {
- pub(crate) async fn new(handle: DaemonHandle, history_db: ClientSqlite) -> Result<Self> {
+ pub(crate) async fn new(handle: DaemonHandle) -> Result<Self> {
let host_id = Settings::host_id().await?;
let history_store =
HistoryStore::new(handle.store().clone(), host_id, *handle.encryption_key());
@@ -55,7 +49,6 @@ impl HistoryService {
running: DashMap::new(),
handle,
history_store,
- history_db,
})
}
@@ -91,18 +84,15 @@ impl HistorySvc for HistoryService {
) -> Result<Response<HistoryReply>, Status> {
let req = request.into_inner();
- let context = current_context(req.session)
- .await
- .map_err(|e| Status::internal(format!("failed to aquire context: {e:?}")))?;
-
let entries = if let Some(range) = req.range {
let from = OffsetDateTime::from_unix_timestamp(range.start as i64).unwrap();
let to = OffsetDateTime::from_unix_timestamp(range.end as i64).unwrap();
- self.history_db.range(from, to).await
+ self.handle.history_db().range(from, to).await
} else {
- self.history_db
- .list(&[], &context, None, false, false)
+ self.handle
+ .history_db()
+ .list(None, None, false, false)
.await
}
.map_err(|e| Status::internal(format!("failed to read db: {e:?}")))?
@@ -203,7 +193,6 @@ impl HistorySvc for HistoryService {
}
#[instrument(skip_all, level = Level::INFO)]
- #[expect(clippy::significant_drop_tightening, reason = "Would be a logic-bug")]
async fn tail_history(
&self,
_request: Request<TailHistoryRequest>,