mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
fix(clients): tolerate orphan client_inbounds rows in Delete
DeleteByEmail's previous fix only covered the case where GetRecordByEmail
returned ErrRecordNotFound. When the ClientRecord exists but a client_inbounds
row points to an inbound that has been removed out-of-band (failed mid-delete,
manual SQL, pre-SyncInbound migration), Delete bubbled the raw gorm
"record not found" from inboundSvc.GetInbound and aborted before any cleanup
ran — leaving the client un-deletable through the UI/API.
Match the tolerance bulkDelInboundClients already has: when GetInbound
returns gorm.ErrRecordNotFound for a join row, log a warning and continue.
The unconditional Delete(&model.ClientInbound{}) later in the function then
removes the stale row, and the ClientRecord delete succeeds.
This commit is contained in:
parent
16b4ca0c26
commit
66b80fb81b
1 changed files with 4 additions and 0 deletions
|
|
@ -678,6 +678,10 @@ func (s *ClientService) Delete(inboundSvc *InboundService, id int, keepTraffic b
|
|||
for _, ibId := range inboundIds {
|
||||
inbound, getErr := inboundSvc.GetInbound(ibId)
|
||||
if getErr != nil {
|
||||
if errors.Is(getErr, gorm.ErrRecordNotFound) {
|
||||
logger.Warningf("Delete: skipping orphan client_inbounds row for client_id=%d, inbound_id=%d (inbound missing)", id, ibId)
|
||||
continue
|
||||
}
|
||||
return needRestart, getErr
|
||||
}
|
||||
key := clientKeyForProtocol(inbound.Protocol, existing)
|
||||
|
|
|
|||
Loading…
Reference in a new issue