Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5664d557
authored
Dec 17, 2024
by
xqx333
Committed by
GitHub
Dec 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update channel.go
parent
33397731
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
model/channel.go
+13
-0
No files found.
model/channel.go
View file @
5664d557
...
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"one-api/common"
"strings"
"sync"
"gorm.io/gorm"
)
...
...
@@ -290,7 +291,19 @@ func (channel *Channel) Delete() error {
return
err
}
var
channelStatusLock
sync
.
Mutex
func
UpdateChannelStatusById
(
id
int
,
status
int
,
reason
string
)
{
if
(
common
.
MemoryCacheEnabled
)
{
channelStatusLock
.
Lock
()
channelCache
,
err
:=
CacheGetChannel
(
id
)
// 如果缓存渠道不存在或渠道已是目标状态,直接返回
if
err
!=
nil
||
channelCache
.
Status
==
status
{
channelStatusLock
.
Unlock
()
return
}
CacheUpdateChannelStatus
(
id
,
status
)
channelStatusLock
.
Unlock
()
}
err
:=
UpdateAbilityStatus
(
id
,
status
==
common
.
ChannelStatusEnabled
)
if
err
!=
nil
{
common
.
SysError
(
"failed to update ability status: "
+
err
.
Error
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment