Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass errors up the stack in CalculateWorld and InstallPackages #1404

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions pkg/apk/apk/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,7 @@ func (a *APK) CalculateWorld(ctx context.Context, allpkgs []*RepositoryPackage)

resolved := make([]*APKResolved, len(allpkgs))

// A slice of pseudo-promises that get closed when expanded[i] is ready.
done := make([]chan struct{}, len(allpkgs))
for i := range allpkgs {
done[i] = make(chan struct{})
}

// Meanwhile, concurrently fetch and expand all our APKs.
// We signal they are ready to be installed by closing done[i].
// concurrently fetch and expand all our APKs.
for i, pkg := range allpkgs {
i, pkg := i, pkg

Expand All @@ -547,8 +540,6 @@ func (a *APK) CalculateWorld(ctx context.Context, allpkgs []*RepositoryPackage)
res.Package = pkg
resolved[i] = res

close(done[i])

return nil
})
}
Expand Down Expand Up @@ -664,6 +655,10 @@ func (a *APK) InstallPackages(ctx context.Context, sourceDateEpoch *time.Time, a
exp := expanded[i]
pkg := allpkgs[i]

if exp == nil {
return fmt.Errorf("expansion of %s failed", pkg)
}

isInstalled, err := a.isInstalledPackage(pkg.PackageName())
if err != nil {
return fmt.Errorf("error checking if package %s is installed: %w", pkg, err)
Expand Down Expand Up @@ -698,13 +693,13 @@ func (a *APK) InstallPackages(ctx context.Context, sourceDateEpoch *time.Time, a
i, pkg := i, pkg

g.Go(func() error {
defer func() { close(done[i]) }()
exp, err := a.expandPackage(ctx, pkg)
if err != nil {
return fmt.Errorf("expanding %s: %w", pkg, err)
}

expanded[i] = exp
close(done[i])

return nil
})
Expand Down
Loading