run clippy fix

This commit is contained in:
Lennart K
2025-10-27 19:01:04 +01:00
parent 08041c60be
commit 0d071d3b92
94 changed files with 455 additions and 484 deletions

View File

@@ -22,7 +22,7 @@ impl TryFrom<CalendarObjectRow> for CalendarObject {
type Error = rustical_store::Error;
fn try_from(value: CalendarObjectRow) -> Result<Self, Self::Error> {
let object = CalendarObject::from_ics(value.ics)?;
let object = Self::from_ics(value.ics)?;
if object.get_id() != value.id {
return Err(rustical_store::Error::IcalError(
rustical_ical::Error::InvalidData(format!(
@@ -213,24 +213,21 @@ impl SqliteCalendarStore {
id: &str,
use_trashbin: bool,
) -> Result<(), Error> {
match use_trashbin {
true => sqlx::query!(
r#"UPDATE calendars SET deleted_at = datetime() WHERE (principal, id) = (?, ?)"#,
principal,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)?,
false => sqlx::query!(
r#"DELETE FROM calendars WHERE (principal, id) = (?, ?)"#,
principal,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)?,
};
if use_trashbin { sqlx::query!(
r#"UPDATE calendars SET deleted_at = datetime() WHERE (principal, id) = (?, ?)"#,
principal,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)? } else { sqlx::query!(
r#"DELETE FROM calendars WHERE (principal, id) = (?, ?)"#,
principal,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)? };
Ok(())
}
@@ -286,7 +283,7 @@ impl SqliteCalendarStore {
.fetch_all(executor)
.await.map_err(crate::Error::from)?
.into_iter()
.map(|row| row.try_into())
.map(std::convert::TryInto::try_into)
.collect()
}
@@ -320,7 +317,7 @@ impl SqliteCalendarStore {
.await
.map_err(crate::Error::from)?
.into_iter()
.map(|row| row.try_into())
.map(std::convert::TryInto::try_into)
.collect()
}
@@ -411,28 +408,25 @@ impl SqliteCalendarStore {
id: &str,
use_trashbin: bool,
) -> Result<(), Error> {
match use_trashbin {
true => {
sqlx::query!(
"UPDATE calendarobjects SET deleted_at = datetime(), updated_at = datetime() WHERE (principal, cal_id, id) = (?, ?, ?)",
principal,
cal_id,
id
)
.execute(executor)
.await.map_err(crate::Error::from)?;
}
false => {
sqlx::query!(
"DELETE FROM calendarobjects WHERE cal_id = ? AND id = ?",
cal_id,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)?;
}
};
if use_trashbin {
sqlx::query!(
"UPDATE calendarobjects SET deleted_at = datetime(), updated_at = datetime() WHERE (principal, cal_id, id) = (?, ?, ?)",
principal,
cal_id,
id
)
.execute(executor)
.await.map_err(crate::Error::from)?;
} else {
sqlx::query!(
"DELETE FROM calendarobjects WHERE cal_id = ? AND id = ?",
cal_id,
id
)
.execute(executor)
.await
.map_err(crate::Error::from)?;
}
Ok(())
}
@@ -484,8 +478,7 @@ impl SqliteCalendarStore {
let new_synctoken = changes
.last()
.map(|&Row { synctoken, .. }| synctoken)
.unwrap_or(0);
.map_or(0, |&Row { synctoken, .. }| synctoken);
for Row { object_id, .. } in changes {
match Self::_get_object(&mut *conn, principal, cal_id, &object_id, false).await {
@@ -562,7 +555,7 @@ impl CalendarStore for SqliteCalendarStore {
})
{
error!("Push notification about deleted calendar failed: {err}");
};
}
Ok(())
}
@@ -627,9 +620,9 @@ impl CalendarStore for SqliteCalendarStore {
let mut deleted_sizes = vec![];
for (size, deleted) in Self::_list_objects(&self.db, principal, cal_id).await? {
if deleted {
deleted_sizes.push(size)
deleted_sizes.push(size);
} else {
sizes.push(size)
sizes.push(size);
}
}
Ok(CollectionMetadata {
@@ -680,8 +673,8 @@ impl CalendarStore for SqliteCalendarStore {
Self::_put_object(
&mut *tx,
principal.to_owned(),
cal_id.to_owned(),
principal.clone(),
cal_id.clone(),
object,
overwrite,
)
@@ -706,7 +699,7 @@ impl CalendarStore for SqliteCalendarStore {
.push_topic,
}) {
error!("Push notification about deleted calendar failed: {err}");
};
}
Ok(())
}
@@ -731,7 +724,7 @@ impl CalendarStore for SqliteCalendarStore {
topic: self.get_calendar(principal, cal_id, true).await?.push_topic,
}) {
error!("Push notification about deleted calendar failed: {err}");
};
}
Ok(())
}
@@ -756,7 +749,7 @@ impl CalendarStore for SqliteCalendarStore {
topic: self.get_calendar(principal, cal_id, true).await?.push_topic,
}) {
error!("Push notification about deleted calendar failed: {err}");
};
}
Ok(())
}