diff --git a/internal/command/providers_lock.go b/internal/command/providers_lock.go index cb6b26f266..d0b82abbe2 100644 --- a/internal/command/providers_lock.go +++ b/internal/command/providers_lock.go @@ -249,8 +249,8 @@ func (c *ProvidersLockCommand) Run(args []string) int { // Use global plugin cache for extra speed if this architecture matches the systems (and therefore the caches) one globalCacheDir := c.providerGlobalCacheDir() - if globalCacheDir != nil && platform == getproviders.CurrentPlatform { - installer.SetGlobalCacheDir(globalCacheDir) + if globalCacheDir != nil { + installer.SetGlobalCacheDir(globalCacheDir.WithPlatform(platform)) installer.SetGlobalCacheDirMayBreakDependencyLockFile(c.PluginCacheMayBreakDependencyLockFile) } diff --git a/internal/providercache/dir.go b/internal/providercache/dir.go index c11a14192e..eab987e453 100644 --- a/internal/providercache/dir.go +++ b/internal/providercache/dir.go @@ -75,6 +75,12 @@ func (d *Dir) BasePath() string { return filepath.Clean(d.baseDir) } +// WithPlatform creates a new dir with the provided platform based +// on this dir +func (d *Dir) WithPlatform(platform getproviders.Platform) *Dir { + return NewDirWithPlatform(d.baseDir, platform) +} + // AllAvailablePackages returns a description of all of the packages already // present in the directory. The cache entries are grouped by the provider // they relate to and then sorted by version precedence, with highest