Skip to content

Commit 8006bef

Browse files
authored
tuistcache: unconditionally presign download cache artifact requests (#806)
1 parent 2a6c0ac commit 8006bef

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

internal/agent/http_cache/tuistcache/tuistcache.go

-12
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,6 @@ func (tc *TuistCache) DownloadCacheArtifact(
5555
) (tuistapi.DownloadCacheArtifactRes, error) {
5656
cacheKey := getCacheKey(params.CacheCategory, params.ProjectID, params.Hash, params.Name)
5757

58-
_, err := client.CirrusClient.CacheInfo(ctx, &api.CacheInfoRequest{
59-
TaskIdentification: client.CirrusTaskIdentification,
60-
CacheKey: cacheKey,
61-
})
62-
if err != nil {
63-
if status, ok := status.FromError(err); ok && status.Code() == codes.NotFound {
64-
return &tuistapi.DownloadCacheArtifactNotFound{}, nil
65-
}
66-
67-
return nil, err
68-
}
69-
7058
generateCacheUploadURLResponse, err := client.CirrusClient.GenerateCacheDownloadURLs(ctx, &api.CacheKey{
7159
TaskIdentification: client.CirrusTaskIdentification,
7260
CacheKey: cacheKey,

internal/agent/http_cache/tuistcache/tuistcache_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ func TestTuistCache(t *testing.T) {
5252
Name: name,
5353
})
5454
require.NoError(t, err)
55-
require.IsType(t, &tuistapi.DownloadCacheArtifactNotFound{}, downloadCacheArtifactResp)
55+
56+
require.IsType(t, &tuistapi.CacheArtifactDownloadURL{}, downloadCacheArtifactResp)
57+
cacheArtifactDownloadUrl := downloadCacheArtifactResp.(*tuistapi.CacheArtifactDownloadURL)
58+
59+
cacheArtifactDownloadUrlResp, err := http.Get(cacheArtifactDownloadUrl.Data.URL)
60+
require.NoError(t, err)
61+
require.Equal(t, http.StatusNotFound, cacheArtifactDownloadUrlResp.StatusCode)
5662

5763
// Create the cache entry
5864
startCacheArtifactMultipartUploadResp, err := tuistCacheClient.StartCacheArtifactMultipartUpload(

0 commit comments

Comments
 (0)