sync: batch file identification via hash lookup
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I85d3f1265cad1996340ac98ac9ee1f7e6a6a6964
This commit is contained in:
parent
0048a1cd73
commit
838ba82790
5 changed files with 261 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue