sync: batch file identification via hash lookup

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I85d3f1265cad1996340ac98ac9ee1f7e6a6a6964
This commit is contained in:
raf 2026-04-18 22:58:31 +03:00
commit 838ba82790
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
5 changed files with 261 additions and 1 deletions

View file

@ -202,4 +202,31 @@ impl PlatformClient for MultiplatformPlatform {
(Err(e), _) | (_, Err(e)) => Err(e),
}
}
async fn request_projects_from_hashes(
&self,
hashes: &[String],
algorithm: &str,
) -> Result<Vec<Project>> {
let cf_future = self
.curseforge
.request_projects_from_hashes(hashes, algorithm);
let mr_future = self
.modrinth
.request_projects_from_hashes(hashes, algorithm);
let (cf_projects, mr_projects) = tokio::join!(cf_future, mr_future);
let mut all_projects = cf_projects?;
for mr_project in mr_projects? {
if !all_projects.iter().any(|p| {
p.id.get("modrinth") == mr_project.id.get("modrinth")
|| p.id.get("curseforge") == mr_project.id.get("curseforge")
}) {
all_projects.push(mr_project);
}
}
Ok(all_projects)
}
}