@@ -7,7 +7,7 @@ import * as core from '@actions/core';
7
7
import * as exec from '@actions/exec' ;
8
8
import * as glob from '@actions/glob' ;
9
9
import * as tc from '@actions/tool-cache' ;
10
- import { rmrf } from './fs ' ;
10
+ import { padDate , rmrf } from './helpers ' ;
11
11
import { RUST_HASH , RUST_VERSION } from './rust' ;
12
12
13
13
export const CARGO_HOME = process . env . CARGO_HOME ?? path . join ( os . homedir ( ) , '.cargo' ) ;
@@ -129,7 +129,19 @@ export async function cleanCargoRegistry() {
129
129
const registryDir = path . join ( CARGO_HOME , 'registry' ) ;
130
130
131
131
// .cargo/registry/src - Delete entirely
132
- await exec . exec ( 'cargo' , [ 'cache' , '--autoclean' ] ) ;
132
+ const staleDate = new Date ( ) ;
133
+
134
+ // eslint-disable-next-line no-magic-numbers
135
+ staleDate . setDate ( staleDate . getDate ( ) - 14 ) ;
136
+
137
+ await exec . exec ( 'cargo' , [
138
+ 'cache' ,
139
+ '--autoclean' ,
140
+ '--remove-if-older-than' ,
141
+ `${ staleDate . getFullYear ( ) } .${ padDate ( staleDate . getMonth ( ) + 1 ) } .${ padDate (
142
+ staleDate . getDate ( ) ,
143
+ ) } `,
144
+ ] ) ;
133
145
134
146
// .cargo/registry/index - Delete .cache directories
135
147
const indexDir = path . join ( registryDir , 'index' ) ;
0 commit comments