feat(anhaenge): Datenmodell und Ablage fuer Termin-Anhaenge
Neue Tabelle event_attachments samt Ablage-Modul. Dateien liegen unter DATA_DIR/attachments, geshardet nach einem servergenerierten Namen -- weder der hochgeladene Dateiname noch die Termin-UID beruehren je einen Pfad, da die UID bei CalDAV-Terminen aus einem fremden Client stammt. Der Dateityp wird an den Bytes bestimmt, nie am Content-Type des Clients. SVG und HTML sind bewusst nicht erlaubt: beide fuehren Skript im Origin der App aus, wo das Sitzungstoken liegt. Aufgeraeumt wird an allen fuenf Loeschpfaden (Termin, Kalender, Gruppe, Benutzer, CalDAV-DELETE), und zwar Zeilen vor dem Commit, Dateien erst danach -- ein Rollback darf keine Bytes verlieren. Der Sweep als Sicherheitsnetz ist implementiert, haengt aber noch an keinem Scheduler. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
6e981e7aea
commit
22a469d449
@@ -7,6 +7,7 @@ from fastapi.responses import Response
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
import attachments_store
|
||||
import dav_util
|
||||
import ical_io
|
||||
import models
|
||||
@@ -391,8 +392,10 @@ def delete_calendar(
|
||||
)
|
||||
if not cal:
|
||||
raise HTTPException(404, "Calendar not found")
|
||||
stale = attachments_store.purge_for_calendars(db, [cal.id])
|
||||
db.delete(cal)
|
||||
db.commit()
|
||||
attachments_store.unlink_all(stale)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@@ -525,8 +528,12 @@ def delete_event(
|
||||
):
|
||||
ev = _writable_event(db, current_user, uid)
|
||||
dav_util.bump_dav(ev.calendar)
|
||||
# Drop the attachment rows here so their files can be named, then unlink
|
||||
# only after the commit — a rollback must not leave rows without bytes.
|
||||
stale = attachments_store.purge_for_events(db, [ev.id])
|
||||
db.delete(ev)
|
||||
db.commit()
|
||||
attachments_store.unlink_all(stale)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user