refac
This commit is contained in:
1 parent
794b97025d
commit
1d892ce2c5
1 file changed
+7
-5
@@ -395,14 +395,16 @@ class CalendarTable:
|
|||||||
# Delete events
|
# Delete events
|
||||||
await db.execute(delete(CalendarEvent).filter(CalendarEvent.calendar_id == id))
|
await db.execute(delete(CalendarEvent).filter(CalendarEvent.calendar_id == id))
|
||||||
|
|
||||||
# Delete access grants
|
|
||||||
await AccessGrants.revoke_all_access('calendar', id, db=db)
|
|
||||||
|
|
||||||
# Delete calendar
|
# Delete calendar
|
||||||
await db.execute(delete(Calendar).filter(Calendar.id == id))
|
await db.execute(delete(Calendar).filter(Calendar.id == id))
|
||||||
await db.commit()
|
await db.commit()
|
||||||
return True
|
|
||||||
except Exception:
|
# Revoke access grants in a separate transaction to avoid
|
||||||
|
# write-lock contention on SQLite when session sharing is off.
|
||||||
|
await AccessGrants.revoke_all_access('calendar', id)
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
log.exception(f'Failed to delete calendar {id}: {e}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user