fix: return Ok after extracting kernel from APK

extract_kernel_from_apk fell through to an unconditional error after a
successful extraction, so every first --kernel run failed after
downloading the 45MB package; the second run worked from cache. Also
remove the downloaded APK even when extraction fails.
This commit is contained in:
2026-09-20 22:36:49 +02:00
parent e1d69eaed6
commit ef00776414
+5 -5
View File
@@ -224,12 +224,11 @@ fn download_alpine_kernel(branch: &str, arch: &str, dest: &Path) -> Result<()> {
// Extract vmlinuz-virt from the APK // Extract vmlinuz-virt from the APK
// APK files are gzip-compressed tar archives // APK files are gzip-compressed tar archives
let temp_apk = dest.with_extension("apk"); let temp_apk = dest.with_extension("apk");
extract_kernel_from_apk(&temp_apk, dest)?; // Remove the ~45MB APK whatever the extraction outcome — don't leave
// it behind in the cache directory on failure.
// Clean up the APK let result = extract_kernel_from_apk(&temp_apk, dest);
std::fs::remove_file(&temp_apk).ok(); std::fs::remove_file(&temp_apk).ok();
result
Ok(())
} }
async fn download_kernel_async(url: &str, dest: &Path) -> Result<()> { async fn download_kernel_async(url: &str, dest: &Path) -> Result<()> {
@@ -316,6 +315,7 @@ fn extract_kernel_from_apk(apk_path: &Path, dest: &Path) -> Result<()> {
// Extract to destination // Extract to destination
entry.unpack(dest).context("Failed to extract kernel")?; entry.unpack(dest).context("Failed to extract kernel")?;
veprintln!(" Extracted kernel to: {}", dest.display()); veprintln!(" Extracted kernel to: {}", dest.display());
return Ok(());
} }
} }