From 0b55d629ccdd57644f56558e7c594bc6e3514bcf Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Mon, 15 May 2023 16:04:07 -0700 Subject: [PATCH] fix: set repoRoot on http cache so cache can be restored (#4956) repoRoot was never passed in before, but in 829e5ac2be31accee0f2bd1c3048ac092e37d01c, changing the implementation of `restoreTar` caused the handling of an empty string for this argument to change. Before, the contents of the tar would get anchored before attempting to write to disk, but in cacheItem, this affordance does not seem to exist. We could add it back, but the implementation looks different enough that it is easier to just pass in the repoRoot. Additionally, there may be other issues with running turbo from subdirectories, since the inferred path from an empty string may be defaulting to cwd, which would be the incorrect place to restore from a remote cache. --- cli/internal/cache/cache.go | 2 +- cli/internal/cache/cache_http.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/internal/cache/cache.go b/cli/internal/cache/cache.go index 8b74272ed10dd..e5e24c1a9d133 100644 --- a/cli/internal/cache/cache.go +++ b/cli/internal/cache/cache.go @@ -129,7 +129,7 @@ func newSyncCache(opts Opts, repoRoot turbopath.AbsoluteSystemPath, client clien } if useHTTPCache { - implementation := newHTTPCache(opts, client, recorder) + implementation := newHTTPCache(opts, client, recorder, repoRoot) cacheImplementations = append(cacheImplementations, implementation) } diff --git a/cli/internal/cache/cache_http.go b/cli/internal/cache/cache_http.go index 0e8d1ce5437b2..f335a954949bc 100644 --- a/cli/internal/cache/cache_http.go +++ b/cli/internal/cache/cache_http.go @@ -267,12 +267,13 @@ func (cache *httpCache) CleanAll() { func (cache *httpCache) Shutdown() {} -func newHTTPCache(opts Opts, client client, recorder analytics.Recorder) *httpCache { +func newHTTPCache(opts Opts, client client, recorder analytics.Recorder, repoRoot turbopath.AbsoluteSystemPath) *httpCache { return &httpCache{ writable: true, client: client, requestLimiter: make(limiter, 20), recorder: recorder, + repoRoot: repoRoot, signerVerifier: &ArtifactSignatureAuthentication{ // TODO(Gaspar): this should use RemoteCacheOptions.TeamId once we start // enforcing team restrictions for repositories.