From 196bafff0387e9c7adffb4964e9718152182bd02 Mon Sep 17 00:00:00 2001 From: CaIon Date: Thu, 31 Jul 2025 10:56:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A2=AB=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=B8=A0=E9=81=93=E6=97=A0=E6=B3=95=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/channel-test.go | 7 +++++-- model/channel_cache.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index 75fec463..3a7c582b 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -332,8 +332,11 @@ func TestChannel(c *gin.Context) { } channel, err := model.CacheGetChannel(channelId) if err != nil { - common.ApiError(c, err) - return + channel, err = model.GetChannelById(channelId, true) + if err != nil { + common.ApiError(c, err) + return + } } //defer func() { // if channel.ChannelInfo.IsMultiKey { diff --git a/model/channel_cache.go b/model/channel_cache.go index 45069ba0..1abc8b85 100644 --- a/model/channel_cache.go +++ b/model/channel_cache.go @@ -239,6 +239,20 @@ func CacheUpdateChannelStatus(id int, status int) { if channel, ok := channelsIDM[id]; ok { channel.Status = status } + if status != common.ChannelStatusEnabled { + // delete the channel from group2model2channels + for group, model2channels := range group2model2channels { + for model, channels := range model2channels { + for i, channelId := range channels { + if channelId == id { + // remove the channel from the slice + group2model2channels[group][model] = append(channels[:i], channels[i+1:]...) + break + } + } + } + } + } } func CacheUpdateChannel(channel *Channel) {