diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4eb68a..2a3edb03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ### 🐛 Bug fixes +- Prevent CLI from returning invalid cached APKs when the download of the build fails. ([#156](https://github.com/expo/orbit/pull/156) by [@gabrieldonadel](https://github.com/gabrieldonadel)) + ### 💡 Others - Fix typo in error alert message. ([#183](https://github.com/expo/orbit/pull/183) by [@prettyClouds](https://github.com/prettyClouds)) diff --git a/packages/eas-shared/src/download.ts b/packages/eas-shared/src/download.ts index c2ac240a..69766670 100644 --- a/packages/eas-shared/src/download.ts +++ b/packages/eas-shared/src/download.ts @@ -138,19 +138,21 @@ export async function downloadAndMaybeExtractAppAsync(url: string): Promise `Downloading app (${formatBytes(total * ratio)} / ${formatBytes(total)})`, 'Successfully downloaded app' ); + // Only move the file to correct location after the download is complete to avoid corrupted files + const apkFilePath = path.join(outputDir, `${uuidv4()}.apk`); + await fs.move(tmpApkFilePath, apkFilePath); return apkFilePath; } else { - const tmpArchivePathDir = path.join(getTmpDirectory(), uuidv4()); - await fs.mkdir(tmpArchivePathDir, { recursive: true }); - const tmpArchivePath = path.join(tmpArchivePathDir, `${uuidv4()}.tar.gz`); await downloadFileWithProgressTrackerAsync(