Skip to content

Commit

Permalink
tuistcache: unconditionally presign download cache artifact requests (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
edigaryev authored Oct 28, 2024
1 parent 2a6c0ac commit 8006bef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 0 additions & 12 deletions internal/agent/http_cache/tuistcache/tuistcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ func (tc *TuistCache) DownloadCacheArtifact(
) (tuistapi.DownloadCacheArtifactRes, error) {
cacheKey := getCacheKey(params.CacheCategory, params.ProjectID, params.Hash, params.Name)

_, err := client.CirrusClient.CacheInfo(ctx, &api.CacheInfoRequest{
TaskIdentification: client.CirrusTaskIdentification,
CacheKey: cacheKey,
})
if err != nil {
if status, ok := status.FromError(err); ok && status.Code() == codes.NotFound {
return &tuistapi.DownloadCacheArtifactNotFound{}, nil
}

return nil, err
}

generateCacheUploadURLResponse, err := client.CirrusClient.GenerateCacheDownloadURLs(ctx, &api.CacheKey{
TaskIdentification: client.CirrusTaskIdentification,
CacheKey: cacheKey,
Expand Down
8 changes: 7 additions & 1 deletion internal/agent/http_cache/tuistcache/tuistcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ func TestTuistCache(t *testing.T) {
Name: name,
})
require.NoError(t, err)
require.IsType(t, &tuistapi.DownloadCacheArtifactNotFound{}, downloadCacheArtifactResp)

require.IsType(t, &tuistapi.CacheArtifactDownloadURL{}, downloadCacheArtifactResp)
cacheArtifactDownloadUrl := downloadCacheArtifactResp.(*tuistapi.CacheArtifactDownloadURL)

cacheArtifactDownloadUrlResp, err := http.Get(cacheArtifactDownloadUrl.Data.URL)
require.NoError(t, err)
require.Equal(t, http.StatusNotFound, cacheArtifactDownloadUrlResp.StatusCode)

// Create the cache entry
startCacheArtifactMultipartUploadResp, err := tuistCacheClient.StartCacheArtifactMultipartUpload(
Expand Down

0 comments on commit 8006bef

Please sign in to comment.