Skip to content

Commit

Permalink
fix: set repoRoot on http cache so cache can be restored (#4956)
Browse files Browse the repository at this point in the history
repoRoot was never passed in before, but in 829e5ac,
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.
  • Loading branch information
mehulkar committed May 15, 2023
1 parent 5ae1c0f commit 0b55d62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/internal/cache/cache.go
Expand Up @@ -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)
}

Expand Down
3 changes: 2 additions & 1 deletion cli/internal/cache/cache_http.go
Expand Up @@ -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.
Expand Down

0 comments on commit 0b55d62

Please sign in to comment.