Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm
logger.Infof("Starting install of %s.%s.%s", pi.Name, pi.Arch, pi.Ver)
fmt.Printf("Installing %s.%s.%s and dependencies...\n", pi.Name, pi.Arch, pi.Ver)
var rs goolib.RepoSpec
var err error
var rsErr error
// If no version is specified, resolve the latest version handling both
// direct matches and providers.
if pi.Ver == "" {
Expand All @@ -180,11 +180,11 @@ func FromRepo(ctx context.Context, pi goolib.PackageInfo, repo, cache string, rm
} else {
// When a specific version is requested, look for an exact match in the repository.
// Virtual package resolution is not currently supported for specific versions.
rs, err = client.FindRepoSpec(pi, rm[repo])
rs, rsErr = client.FindRepoSpec(pi, rm[repo])
}

if err != nil {
return err
if rsErr != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loses the error from line 179. I think a better way to fix this would be to drop the predeclared outer err/rsErr entirely and instead pull the client.FindRepoSpec call out of the if-else block so that it only happens once. This seems to be what was actually intended, based on the fact that pi gets updated inside the if pi.Ver = "" case.

return rsErr
}
if err := installDeps(ctx, rs.PackageSpec, cache, rm, archs, dbOnly, downloader, db); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func TestFromRepo_SatisfiedByProvider(t *testing.T) {

// We pass empty repo map and downloader because we expect it NOT to try downloading deps
// since they are satisfied.
err = installDeps(nil, ps, "", nil, nil, false, nil, db)
err = installDeps(t.Context(), ps, "", nil, nil, false, nil, db)
if err != nil {
t.Errorf("installDeps failed: %v", err)
}
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestFromRepo_SatisfiedByUninstalledProvider(t *testing.T) {
// Verify that dependency resolution succeeds (finding provider_pkg); the download
// is expected to fail due to an invalid repository URL.
downloader, _ := client.NewDownloader("")
err = installDeps(nil, ps, "", rm, []string{"noarch"}, false, downloader, db)
err = installDeps(t.Context(), ps, "", rm, []string{"noarch"}, false, downloader, db)

// We expect an error because download will fail (invalid URL/Source).
if err == nil {
Expand Down
Loading