mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 14:42:30 +00:00
calendar import: log added events
This commit is contained in:
@@ -351,9 +351,9 @@ impl SqliteCalendarStore {
|
||||
#[instrument]
|
||||
async fn _put_object<'e, E: Executor<'e, Database = Sqlite>>(
|
||||
executor: E,
|
||||
principal: String,
|
||||
cal_id: String,
|
||||
object: CalendarObject,
|
||||
principal: &str,
|
||||
cal_id: &str,
|
||||
object: &CalendarObject,
|
||||
overwrite: bool,
|
||||
) -> Result<(), Error> {
|
||||
let (object_id, uid, ics) = (object.get_id(), object.get_uid(), object.get_ics());
|
||||
@@ -600,18 +600,35 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Self::_insert_calendar(&mut *tx, calendar.clone()).await?;
|
||||
}
|
||||
|
||||
let mut sync_token = None;
|
||||
for object in objects {
|
||||
Self::_put_object(
|
||||
&mut *tx,
|
||||
calendar.principal.clone(),
|
||||
calendar.id.clone(),
|
||||
object,
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
Self::_put_object(&mut *tx, &calendar.principal, &calendar.id, &object, false).await?;
|
||||
|
||||
sync_token = Some(
|
||||
log_object_operation(
|
||||
&mut tx,
|
||||
&calendar.principal,
|
||||
&calendar.id,
|
||||
object.get_id(),
|
||||
ChangeOperation::Add,
|
||||
)
|
||||
.await?,
|
||||
);
|
||||
}
|
||||
|
||||
tx.commit().await.map_err(crate::Error::from)?;
|
||||
|
||||
if let Some(sync_token) = sync_token
|
||||
&& let Err(err) = self.sender.try_send(CollectionOperation {
|
||||
data: CollectionOperationInfo::Content { sync_token },
|
||||
topic: self
|
||||
.get_calendar(&calendar.principal, &calendar.id, true)
|
||||
.await?
|
||||
.push_topic,
|
||||
})
|
||||
{
|
||||
error!("Push notification about deleted calendar failed: {err}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -689,14 +706,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
return Err(Error::ReadOnly);
|
||||
}
|
||||
|
||||
Self::_put_object(
|
||||
&mut *tx,
|
||||
principal.clone(),
|
||||
cal_id.clone(),
|
||||
object,
|
||||
overwrite,
|
||||
)
|
||||
.await?;
|
||||
Self::_put_object(&mut *tx, &principal, &cal_id, &object, overwrite).await?;
|
||||
|
||||
let sync_token = log_object_operation(
|
||||
&mut tx,
|
||||
|
||||
Reference in New Issue
Block a user