mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 13:29:10 +08:00 
			
		
		
		
	Adds input for upload chunk size
This commit is contained in:
		@@ -1,7 +1,8 @@
 | 
			
		||||
export enum Inputs {
 | 
			
		||||
    Key = "key",
 | 
			
		||||
    Path = "path",
 | 
			
		||||
    RestoreKeys = "restore-keys"
 | 
			
		||||
    RestoreKeys = "restore-keys",
 | 
			
		||||
    UploadChunkSize = "upload-chunk-size"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum Outputs {
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,9 @@ async function run(): Promise<void> {
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            await cache.saveCache(cachePaths, primaryKey);
 | 
			
		||||
            await cache.saveCache(cachePaths, primaryKey, {
 | 
			
		||||
                uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
 | 
			
		||||
            });
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
            if (error.name === cache.ValidationError.name) {
 | 
			
		||||
                throw error;
 | 
			
		||||
 
 | 
			
		||||
@@ -63,3 +63,14 @@ export function getInputAsArray(
 | 
			
		||||
        .map(s => s.trim())
 | 
			
		||||
        .filter(x => x !== "");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function getInputAsInt(
 | 
			
		||||
    name: string,
 | 
			
		||||
    options?: core.InputOptions
 | 
			
		||||
): number | undefined {
 | 
			
		||||
    const value = Number(core.getInput(name, options));
 | 
			
		||||
    if (Number.isNaN(value) || value < 0) {
 | 
			
		||||
        return undefined;
 | 
			
		||||
    }
 | 
			
		||||
    return value;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,4 +26,5 @@ export function clearInputs(): void {
 | 
			
		||||
    delete process.env[getInputName(Inputs.Path)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.Key)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.RestoreKeys)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.UploadChunkSize)];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user