mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-19 12:50:51 +08:00
fix(gemini-web): Correct ambiguity check in conversation lookup
This commit is contained in:
@@ -108,6 +108,8 @@ func LookupMatch(hash string) (MatchRecord, bool, error) {
|
|||||||
return MatchRecord{}, false, err
|
return MatchRecord{}, false, err
|
||||||
}
|
}
|
||||||
var foundOne bool
|
var foundOne bool
|
||||||
|
var ambiguous bool
|
||||||
|
var firstLabel string
|
||||||
var single MatchRecord
|
var single MatchRecord
|
||||||
err = db.View(func(tx *bolt.Tx) error {
|
err = db.View(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket([]byte(bucketMatches))
|
bucket := tx.Bucket([]byte(bucketMatches))
|
||||||
@@ -129,12 +131,18 @@ func LookupMatch(hash string) (MatchRecord, bool, error) {
|
|||||||
if strings.TrimSpace(rec.AccountLabel) == "" || rec.PrefixLen <= 0 {
|
if strings.TrimSpace(rec.AccountLabel) == "" || rec.PrefixLen <= 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if foundOne {
|
label := strings.ToLower(strings.TrimSpace(rec.AccountLabel))
|
||||||
// More than one distinct label exists for this hash; ambiguous.
|
if !foundOne {
|
||||||
return nil
|
firstLabel = label
|
||||||
}
|
|
||||||
single = rec
|
single = rec
|
||||||
foundOne = true
|
foundOne = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if label != firstLabel {
|
||||||
|
ambiguous = true
|
||||||
|
// Early exit scan; ambiguity detected.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if foundOne {
|
if foundOne {
|
||||||
return nil
|
return nil
|
||||||
@@ -149,6 +157,9 @@ func LookupMatch(hash string) (MatchRecord, bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return MatchRecord{}, false, err
|
return MatchRecord{}, false, err
|
||||||
}
|
}
|
||||||
|
if ambiguous {
|
||||||
|
return MatchRecord{}, false, nil
|
||||||
|
}
|
||||||
if strings.TrimSpace(single.AccountLabel) == "" || single.PrefixLen <= 0 {
|
if strings.TrimSpace(single.AccountLabel) == "" || single.PrefixLen <= 0 {
|
||||||
return MatchRecord{}, false, nil
|
return MatchRecord{}, false, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user