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
316c0a59
authored
Aug 02, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: retain polling index for multi-key channels during sync
parent
f0b024eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
model/channel_cache.go
+10
-6
No files found.
model/channel_cache.go
View file @
316c0a59
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"math/rand"
"one-api/common"
"one-api/constant"
"one-api/setting"
"sort"
"strings"
...
...
@@ -66,6 +67,15 @@ func InitChannelCache() {
channelSyncLock
.
Lock
()
group2model2channels
=
newGroup2model2channels
//channelsIDM = newChannelId2channel
for
i
,
channel
:=
range
newChannelId2channel
{
if
oldChannel
,
ok
:=
channelsIDM
[
i
];
ok
{
// 存在旧的渠道,如果是多key且轮询,保留轮询索引信息
if
oldChannel
.
ChannelInfo
.
IsMultiKey
&&
oldChannel
.
ChannelInfo
.
MultiKeyMode
==
constant
.
MultiKeyModePolling
{
channel
.
ChannelInfo
.
MultiKeyPollingIndex
=
oldChannel
.
ChannelInfo
.
MultiKeyPollingIndex
}
}
}
channelsIDM
=
newChannelId2channel
channelSyncLock
.
Unlock
()
common
.
SysLog
(
"channels synced from database"
)
...
...
@@ -203,9 +213,6 @@ func CacheGetChannel(id int) (*Channel, error) {
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"渠道# %d,已不存在"
,
id
)
}
if
c
.
Status
!=
common
.
ChannelStatusEnabled
{
return
nil
,
fmt
.
Errorf
(
"渠道# %d,已被禁用"
,
id
)
}
return
c
,
nil
}
...
...
@@ -224,9 +231,6 @@ func CacheGetChannelInfo(id int) (*ChannelInfo, error) {
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"渠道# %d,已不存在"
,
id
)
}
if
c
.
Status
!=
common
.
ChannelStatusEnabled
{
return
nil
,
fmt
.
Errorf
(
"渠道# %d,已被禁用"
,
id
)
}
return
&
c
.
ChannelInfo
,
nil
}
...
...
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