@@ -6,8 +6,7 @@ import * as download from "./download";
66
77interface Options {
88 useToolCache : boolean ;
9- primaryKey ?: string ;
10- restoreKeys ?: string [ ] ;
9+ useCache : boolean ;
1110}
1211
1312async function downloadFromToolCache (
@@ -29,36 +28,25 @@ export async function run(
2928 version : string ,
3029 options : Options
3130) : Promise < void > {
32- try {
33- if ( options . useToolCache ) {
34- try {
35- core . info (
36- "Tool cache is explicitly enabled via the Action input"
37- ) ;
38- core . startGroup ( "Downloading from the tool cache" ) ;
39-
40- return await downloadFromToolCache ( crate , version ) ;
41- } finally {
42- core . endGroup ( ) ;
43- }
44- } else {
45- core . info (
46- "Tool cache is disabled in the Action inputs, skipping it"
47- ) ;
31+ if ( options . useToolCache ) {
32+ try {
33+ core . info ( "Tool cache is explicitly enabled via the Action input" ) ;
34+ core . startGroup ( "Downloading from the tool cache" ) ;
4835
49- throw new Error (
50- "Faster installation options either failed or disabled"
51- ) ;
36+ return await downloadFromToolCache ( crate , version ) ;
37+ } finally {
38+ core . endGroup ( ) ;
5239 }
53- } catch ( error ) {
54- core . info ( "Falling back to the `cargo install` command " ) ;
40+ } else if ( options . useCache ) {
41+ core . info ( "GitHub Actions cache is used to install the tool " ) ;
5542 const cargo = await Cargo . get ( ) ;
56- await cargo . installCached (
57- crate ,
58- version ,
59- options . primaryKey ,
60- options . restoreKeys
43+ await cargo . installCached ( crate , version ) ;
44+ } else {
45+ core . info (
46+ "Cache is disabled. Falling back to the `cargo install` command"
6147 ) ;
48+ const cargo = await Cargo . get ( ) ;
49+ await cargo . install ( crate , version ) ;
6250 }
6351}
6452
@@ -68,8 +56,7 @@ async function main(): Promise<void> {
6856
6957 await run ( actionInput . crate , actionInput . version , {
7058 useToolCache : actionInput . useToolCache ,
71- primaryKey : actionInput . primaryKey ,
72- restoreKeys : actionInput . restoreKeys ,
59+ useCache : actionInput . useCache ,
7360 } ) ;
7461 } catch ( error ) {
7562 core . setFailed ( error . message ) ;
0 commit comments