Skip to content

Commit 9d4524b

Browse files
committed
fix: fingerprint response 的 id 应该是 modId
哈哈哈,蒙在鼓里整整一年,为什么 Meloong-Git/PCL#6656 (comment) exactMatches 的 id 是 modId 啊 `'': [{'id': 912121, 'file': {'id': 5559269, 'gameId': 432, 'modId': 912121, ` 疯了疯了
1 parent 609bfde commit 9d4524b

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/models/curseforge/responses.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ use utoipa::ToSchema;
55
use crate::models::curseforge::entities::{Author, FileIndex, Links, Logo, ScreenShot};
66

77
use crate::models::curseforge::entities::{
8-
Category, CategoryInfo, File, FileInfo, Fingerprint, Mod,
8+
Category, CategoryInfo, File, FileInfo, Mod,
99
};
1010

1111
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
1212
pub struct FingerprintResult {
1313
#[serde(rename = "isCacheBuilt")]
1414
pub is_cache_built: bool,
1515
#[serde(rename = "exactMatches")]
16-
// pub exact_matches: Vec<FingerprintResponseObject>,
17-
pub exact_matches: Vec<Fingerprint>,
16+
pub exact_matches: Vec<SingleFingerprintResponse>,
1817
#[serde(rename = "exactFingerprints")]
1918
pub exact_fingerprints: Vec<i64>,
2019
#[serde(rename = "installedFingerprints")]
@@ -23,6 +22,17 @@ pub struct FingerprintResult {
2322
pub unmatched_fingerprints: Vec<i64>,
2423
}
2524

25+
#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
26+
pub struct SingleFingerprintResponse {
27+
pub id: i32,
28+
pub file: FileInfo,
29+
#[serde(rename = "latestFiles")]
30+
pub latest_files: Vec<FileInfo>,
31+
32+
pub sync_at: DateTime<Utc>,
33+
}
34+
35+
2636
// #[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]
2737
// pub struct _FileSortableGameVersions {
2838
// #[serde(rename = "gameVersionName")]

src/services/curseforge.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,18 @@ impl CurseforgeService {
610610

611611
let exact_fingerprints = fingerprint_results.iter().map(|f| f.id).collect();
612612

613+
// 用 SingleFingerprintResponse, 将 id 设置为 fingerprint.file.modId
614+
// https://github.com/Meloong-Git/PCL/issues/6656
615+
let exact_matches = fingerprint_results
616+
.iter()
617+
.map(|f| SingleFingerprintResponse {
618+
id: f.file.mod_id,
619+
file: f.file.clone(),
620+
latest_files: f.latest_files.clone(),
621+
sync_at: f.sync_at,
622+
})
623+
.collect::<Vec<_>>();
624+
613625
let unmatched_fingerprints: Vec<i64> = fingerprints
614626
.into_iter()
615627
.filter(|f| !fingerprint_results.iter().any(|fp| fp.id == *f))
@@ -624,8 +636,8 @@ impl CurseforgeService {
624636

625637
let response = FingerprintResponse {
626638
data: FingerprintResult {
627-
is_cache_built: true,
628-
exact_matches: fingerprint_results,
639+
is_cache_built: true, // 默认值,没见过 false
640+
exact_matches: exact_matches,
629641
exact_fingerprints: exact_fingerprints,
630642
installed_fingerprints: Vec::new(),
631643
unmatched_fingerprints: unmatched_fingerprints,

0 commit comments

Comments
 (0)