Skip to content

build: preserve IPA output on extraction failure - #38

Merged
Interlap01 merged 1 commit into
MobAI-App:mainfrom
sunjinshuai:codex/fix-atomic-ipa-extraction
Oct 6, 2026
Merged

Interlap01 merged 1 commit into
MobAI-App:mainfrom
sunjinshuai:codex/fix-atomic-ipa-extraction

Conversation

@sunjinshuai

Copy link
Copy Markdown
Contributor

Description

A failed GitHub artifact extraction leaves a corrupt .ipa in the output directory, or overwrites a previously valid file at the same destination. Save to a temporary file in the destination directory and rename it only after copying and closing succeed. Remove the temporary file on every exit path, matching the existing external-provider download pattern.

Reproduction and root cause

Create an artifact ZIP containing a stored App.ipa entry and flip one payload byte without updating its CRC. extractIPAFromZip returns zip.ErrChecksum, but extractFile has already created/truncated the final destination and copied the corrupt bytes into it. The failed build therefore leaves a fresh *.ipa that later commands can select through ipa.Newest.

The regression test reproduces both cases: no previous destination and an existing destination. Before the fix, both fail because corrupt bytes remain at the final path. After the fix, no new IPA is published and an existing file retains its original bytes.

Related Issue

No existing issue; checked open issues and pull requests for duplicates.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • My code follows the project's coding standards
  • Formatting is clean and go vet ./... passes
  • I have added tests that prove my fix works
  • All new and existing tests pass
  • No user-facing documentation change is needed
  • My changes don't introduce new warnings

Testing

Passed locally on macOS arm64:

  • go test ./internal/build -run TestExtractIPAFromZip -count=1 -v: checksum failures preserve or omit the destination, successful extraction replaces the destination, and a rename failure leaves no temporary file.
  • go test -race ./... (Go 1.27.1).
  • GOTOOLCHAIN=go1.26.0 go test ./....
  • GOTOOLCHAIN=go1.24.0 go test ./internal/build.
  • go vet ./..., gofmt -l . (empty), golangci-lint run --timeout=5m (v2.14.0, 0 issues), and git diff --check.
  • CLI builds for darwin/arm64, linux/amd64, and windows/amd64.

Cloud builds and live Apple uploads were not run; the failure is reproduced entirely with a local ZIP fixture.

@Interlap01

Copy link
Copy Markdown
Collaborator

Lgtm. Thank you!

@Interlap01
Interlap01 merged commit 5043823 into MobAI-App:main Oct 6, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants