aboutsummaryrefslogtreecommitdiff
path: root/aero-collections/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-05-28 16:03:25 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-05-28 16:03:25 +0200
commit18f2154151b2cf81e03bdda28fa2ea5d685e33d1 (patch)
treea6fae34924e2808eb65276919d671718adbfbd44 /aero-collections/src
parent171a762768aabd799a1012d2fb939d869ff53f7b (diff)
downloadaerogramme-18f2154151b2cf81e03bdda28fa2ea5d685e33d1.tar.gz
aerogramme-18f2154151b2cf81e03bdda28fa2ea5d685e33d1.zip
implement propfind sync-token
Diffstat (limited to 'aero-collections/src')
-rw-r--r--aero-collections/src/calendar/mod.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/aero-collections/src/calendar/mod.rs b/aero-collections/src/calendar/mod.rs
index cd05328..414426a 100644
--- a/aero-collections/src/calendar/mod.rs
+++ b/aero-collections/src/calendar/mod.rs
@@ -56,6 +56,11 @@ impl Calendar {
self.internal.read().await.davdag.state().clone()
}
+ /// Access the current token
+ pub async fn token(&self) -> Result<Token> {
+ self.internal.write().await.current_token().await
+ }
+
/// The diff API is a write API as we might need to push a merge node
/// to get a new sync token
pub async fn diff(&self, sync_token: Token) -> Result<(Token, Vec<SyncChange>)> {
@@ -174,6 +179,12 @@ impl CalendarInternal {
.map(|s| s.clone())
.collect();
+ let token = self.current_token().await?;
+ Ok((token, changes))
+ }
+
+ async fn current_token(&mut self) -> Result<Token> {
+ let davstate = self.davdag.state();
let heads = davstate.heads_vec();
let token = match heads.as_slice() {
[token] => *token,
@@ -184,7 +195,6 @@ impl CalendarInternal {
token
}
};
-
- Ok((token, changes))
+ Ok(token)
}
}