various: resolve multi-platform lookup; improve error messages
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Iec6ee73639d0b42c96127db657575ab86a6a6964
This commit is contained in:
parent
0f8719eb52
commit
1079635cb9
5 changed files with 232 additions and 25 deletions
|
|
@ -35,8 +35,10 @@ async fn resolve_input(
|
|||
platforms: &HashMap<String, Box<dyn crate::platform::PlatformClient>>,
|
||||
lockfile: &LockFile,
|
||||
) -> Result<Project> {
|
||||
for platform in platforms.values() {
|
||||
if let Ok(project) = platform
|
||||
let mut projects = Vec::new();
|
||||
|
||||
for (platform_name, client) in platforms {
|
||||
match client
|
||||
.request_project_with_files(
|
||||
input,
|
||||
&lockfile.mc_versions,
|
||||
|
|
@ -44,11 +46,29 @@ async fn resolve_input(
|
|||
)
|
||||
.await
|
||||
{
|
||||
return Ok(project);
|
||||
Ok(project) => {
|
||||
log::debug!("Resolved '{input}' on {platform_name}");
|
||||
projects.push(project);
|
||||
},
|
||||
Err(e) => {
|
||||
log::debug!("Could not resolve '{input}' on {platform_name}: {e}");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Err(PakkerError::ProjectNotFound(input.to_string()))
|
||||
if projects.is_empty() {
|
||||
return Err(PakkerError::ProjectNotFound(input.to_string()));
|
||||
}
|
||||
|
||||
if projects.len() == 1 {
|
||||
return Ok(projects.remove(0));
|
||||
}
|
||||
|
||||
let mut merged = projects.remove(0);
|
||||
for project in projects {
|
||||
merged.merge(project);
|
||||
}
|
||||
Ok(merged)
|
||||
}
|
||||
|
||||
use std::path::Path;
|
||||
|
|
@ -111,16 +131,24 @@ pub async fn execute(
|
|||
}
|
||||
|
||||
// Load parent lockfile to get metadata
|
||||
let parent_lockfile = parent_paths
|
||||
let parent_lock_path = parent_paths
|
||||
.iter()
|
||||
.find(|path| path.exists())
|
||||
.and_then(|path| LockFile::load(path.parent()?).ok())
|
||||
.ok_or_else(|| {
|
||||
PakkerError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"Failed to load parent lockfile metadata",
|
||||
"Parent lockfile not found at expected paths",
|
||||
))
|
||||
})?;
|
||||
let parent_lockfile = LockFile::load_with_validation(
|
||||
parent_lock_path.parent().ok_or_else(|| {
|
||||
PakkerError::IoError(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
"Parent lockfile path has no parent directory",
|
||||
))
|
||||
})?,
|
||||
false,
|
||||
)?;
|
||||
|
||||
let minimal_lockfile = LockFile {
|
||||
target: parent_lockfile.target,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue