diff --git a/src/platform/curseforge.rs b/src/platform/curseforge.rs index f1f8008..2cc7b90 100644 --- a/src/platform/curseforge.rs +++ b/src/platform/curseforge.rs @@ -404,6 +404,8 @@ impl PlatformClient for CurseForgePlatform { } } + /// Uses CurseForge's `/fingerprints/432` endpoint to resolve projects by + /// their hashes in batch. async fn request_projects_from_hashes( &self, hashes: &[String], diff --git a/src/platform/github.rs b/src/platform/github.rs index 57582ea..802e3c7 100644 --- a/src/platform/github.rs +++ b/src/platform/github.rs @@ -414,6 +414,20 @@ impl PlatformClient for GitHubPlatform { Err(e) => Err(e), } } + + /// GitHub does not support hash-based batch lookup. Returns an empty list. + async fn request_projects_from_hashes( + &self, + hashes: &[String], + algorithm: &str, + ) -> Result> { + log::debug!( + "GitHub does not support batch hash lookup ({} hashes, algorithm={})", + hashes.len(), + algorithm + ); + Ok(Vec::new()) + } } // GitHub API models diff --git a/src/platform/modrinth.rs b/src/platform/modrinth.rs index 906a264..94ebf84 100644 --- a/src/platform/modrinth.rs +++ b/src/platform/modrinth.rs @@ -277,6 +277,8 @@ impl PlatformClient for ModrinthPlatform { Ok(Some(self.convert_project(mr_project))) } + /// Uses Modrinth's `/v2/version_files` endpoint to resolve projects by + /// their hashes in batch. async fn request_projects_from_hashes( &self, hashes: &[String], diff --git a/src/platform/multiplatform.rs b/src/platform/multiplatform.rs index 5ff8a8b..521f4ec 100644 --- a/src/platform/multiplatform.rs +++ b/src/platform/multiplatform.rs @@ -203,6 +203,8 @@ impl PlatformClient for MultiplatformPlatform { } } + /// Delegates to both CurseForge and Modrinth in parallel, then deduplicates + /// results. async fn request_projects_from_hashes( &self, hashes: &[String], diff --git a/src/platform/traits.rs b/src/platform/traits.rs index db115c9..8319480 100644 --- a/src/platform/traits.rs +++ b/src/platform/traits.rs @@ -37,4 +37,17 @@ pub trait PlatformClient: Send + Sync { &self, slug: &str, ) -> Result>; + + /// Request multiple projects by their hashes (Modrinth) or bytes + /// (CurseForge). + /// + /// # Returns + /// + /// A list of projects found. Platforms that do not support hash-based + /// lookup return an empty list. + async fn request_projects_from_hashes( + &self, + hashes: &[String], + algorithm: &str, + ) -> Result>; }