fix(subscription): prevent duplicate qb downloads

This commit is contained in:
ShukeBta
2026-06-07 10:05:49 +08:00
parent 22b64d3d47
commit d94330b30f
22 changed files with 990 additions and 75 deletions
+18
View File
@@ -3,6 +3,7 @@ package service
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/ShukeBta/MediaStationGo/internal/model"
@@ -101,6 +102,23 @@ func TestSiteSearchKeywordCanUseIMDB(t *testing.T) {
}
}
func TestStableSiteSearchGUIDIgnoresPrivateTokenChanges(t *testing.T) {
item := SearchResult{
SiteID: "mteam",
Title: "Some Show S01E01 1080p",
Category: "TV",
Size: 1024,
}
first := stableSiteSearchGUID(item, "https://pt.example/download?id=123&passkey=old")
second := stableSiteSearchGUID(item, "https://pt.example/download?id=123&passkey=new")
if first != second {
t.Fatalf("stableSiteSearchGUID changed with token: %q != %q", first, second)
}
if strings.Contains(first, "passkey") || strings.Contains(first, "old") || strings.Contains(first, "new") {
t.Fatalf("stableSiteSearchGUID leaked private token: %q", first)
}
}
func TestSelectSiteSearchCandidatesOnlyQueuesMissingLocalEpisodes(t *testing.T) {
sub := &model.Subscription{Name: "间谍过家家 自动订阅", Filter: "间谍过家家", MediaType: "tv", TotalEpisodes: 3}
results := []SearchResult{