Skip to content

Commit

Permalink
Reuse installed target dir providers in init
Browse files Browse the repository at this point in the history
In init, we can check to see if the target dir already has the
provider we are seeking and skip further querying/installing of
that provider.
  • Loading branch information
pselle committed Jan 25, 2021
1 parent bd6b973 commit cf0fcd7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/providercache/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ NeedProvider:
preferredHashes = lock.PreferredHashes()
}

// If our target directory already has the provider version that fulfills the lock file, carry on
if installed := i.targetDir.ProviderVersion(provider, version); installed != nil {
if len(preferredHashes) > 0 {
if matches, err := installed.MatchesAnyHash(preferredHashes); err != nil {
return nil, fmt.Errorf(
"failed to calculate checksum for installed copy of %s %s in %s: %s",
installed.Provider, installed.Version, i.targetDir.baseDir, err,
)
} else if matches {
continue
}
}
}

if i.globalCacheDir != nil {
// Step 3a: If our global cache already has this version available then
// we'll just link it in.
Expand Down

0 comments on commit cf0fcd7

Please sign in to comment.