export: make project file download failures non-fatal
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I33ac734179c7346151e6089d4fc715916a6a6964
This commit is contained in:
parent
86b598b431
commit
dc4c00ac4a
1 changed files with 27 additions and 19 deletions
|
|
@ -87,7 +87,7 @@ impl Effect for CopyProjectFilesEffect {
|
|||
}
|
||||
log::info!("fetched {} (local)", file.file_name);
|
||||
} else if !file.url.is_empty() {
|
||||
download_file(
|
||||
match download_file(
|
||||
&context.base_path,
|
||||
&type_dir,
|
||||
&file.file_name,
|
||||
|
|
@ -95,28 +95,36 @@ impl Effect for CopyProjectFilesEffect {
|
|||
curseforge_key.as_deref(),
|
||||
modrinth_token.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Copy into export dir after ensuring it is present in base dir
|
||||
let downloaded =
|
||||
context.base_path.join(&type_dir).join(&file.file_name);
|
||||
if downloaded.exists() {
|
||||
fs::copy(&downloaded, &dest)?;
|
||||
if let Some(ui) = &context.ui {
|
||||
ui.println(format!("fetched {} (download)", file.file_name));
|
||||
}
|
||||
log::info!("fetched {} (download)", file.file_name);
|
||||
} else {
|
||||
return Err(crate::error::PakkerError::InternalError(format!(
|
||||
"download reported success but file is missing: {}",
|
||||
file.file_name
|
||||
)));
|
||||
.await
|
||||
{
|
||||
Ok(()) => {
|
||||
let downloaded =
|
||||
context.base_path.join(&type_dir).join(&file.file_name);
|
||||
if downloaded.exists() {
|
||||
fs::copy(&downloaded, &dest)?;
|
||||
if let Some(ui) = &context.ui {
|
||||
ui.println(format!("fetched {} (download)", file.file_name));
|
||||
}
|
||||
log::info!("fetched {} (download)", file.file_name);
|
||||
} else {
|
||||
log::warn!(
|
||||
"download reported success but file is missing: {}",
|
||||
file.file_name
|
||||
);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"failed to download {} (continuing): {e}",
|
||||
file.file_name
|
||||
);
|
||||
},
|
||||
}
|
||||
} else {
|
||||
return Err(crate::error::PakkerError::InternalError(format!(
|
||||
log::warn!(
|
||||
"missing project file and no download url: {}",
|
||||
file.file_name
|
||||
)));
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue