Add cross os opt-in functionality for cache on windows

This commit is contained in:
Sampark Sharma
2022-12-29 12:45:10 +00:00
committed by GitHub
parent 2867e318d4
commit ec3a87298b
3 changed files with 30 additions and 10 deletions
+21 -8
View File
@@ -73,13 +73,18 @@ function createHttpClient(): HttpClient {
export function getCacheVersion(
paths: string[],
compressionMethod?: CompressionMethod
compressionMethod?: CompressionMethod,
crossOsEnabled = false
): string {
const components = paths.concat(
!compressionMethod || compressionMethod === CompressionMethod.Gzip
? []
: [compressionMethod]
)
const components = paths
.concat(
!compressionMethod || compressionMethod === CompressionMethod.Gzip
? []
: [compressionMethod]
)
.concat(
process.platform !== 'win32' || crossOsEnabled ? [] : ['windows-only']
) // Only check for windows platforms if crossOsEnabled is false
// Add salt to cache version to support breaking changes in cache entry
components.push(versionSalt)
@@ -96,7 +101,11 @@ export async function getCacheEntry(
options?: InternalCacheOptions
): Promise<ArtifactCacheEntry | null> {
const httpClient = createHttpClient()
const version = getCacheVersion(paths, options?.compressionMethod)
const version = getCacheVersion(
paths,
options?.compressionMethod,
options?.crossOsEnabled
)
const resource = `cache?keys=${encodeURIComponent(
keys.join(',')
)}&version=${version}`
@@ -181,7 +190,11 @@ export async function reserveCache(
options?: InternalCacheOptions
): Promise<ITypedResponseWithError<ReserveCacheResponse>> {
const httpClient = createHttpClient()
const version = getCacheVersion(paths, options?.compressionMethod)
const version = getCacheVersion(
paths,
options?.compressionMethod,
options?.crossOsEnabled
)
const reserveCacheRequest: ReserveCacheRequest = {
key,
+2 -1
View File
@@ -34,8 +34,9 @@ export interface ReserveCacheResponse {
}
export interface InternalCacheOptions {
compressionMethod?: CompressionMethod
cacheSize?: number
compressionMethod?: CompressionMethod
crossOsEnabled?: boolean
}
export interface ArchiveTool {