fix(federation): cascade delete peer_share_runtime rows on share deletion

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
sagit
2026-02-10 11:56:40 +00:00
parent cec5fe9adb
commit 919339cdb1
+10 -2
View File
@@ -1335,8 +1335,16 @@ func (r *Repository) DeletePeerShare(id int64) error {
if r == nil || r.db == nil {
return errors.New("repository not initialized")
}
_, err := r.db.Exec(`DELETE FROM peer_share WHERE id=?`, id)
return err
tx, err := r.db.Begin()
if err != nil {
return err
}
defer func() { _ = tx.Rollback() }()
_, _ = tx.Exec(`DELETE FROM peer_share_runtime WHERE share_id = ?`, id)
if _, err := tx.Exec(`DELETE FROM peer_share WHERE id=?`, id); err != nil {
return err
}
return tx.Commit()
}
func (r *Repository) GetPeerShare(id int64) (*PeerShare, error) {