mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-11 19:56:37 +08:00
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:
@@ -1335,8 +1335,16 @@ func (r *Repository) DeletePeerShare(id int64) error {
|
|||||||
if r == nil || r.db == nil {
|
if r == nil || r.db == nil {
|
||||||
return errors.New("repository not initialized")
|
return errors.New("repository not initialized")
|
||||||
}
|
}
|
||||||
_, err := r.db.Exec(`DELETE FROM peer_share WHERE id=?`, id)
|
tx, err := r.db.Begin()
|
||||||
return err
|
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) {
|
func (r *Repository) GetPeerShare(id int64) (*PeerShare, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user