@@ -76,11 +76,12 @@ export function init(cacheDir: string): string {
76
76
77
77
export async function cleanup ( ) : Promise < void > {
78
78
logger . debug ( 'Checking file package cache for expired items' ) ;
79
- try {
80
- let totalCount = 0 ;
81
- let deletedCount = 0 ;
82
- const startTime = Date . now ( ) ;
83
- for await ( const item of cacache . ls . stream ( cacheFileName ) ) {
79
+ let totalCount = 0 ;
80
+ let deletedCount = 0 ;
81
+ const startTime = Date . now ( ) ;
82
+ let errorCount = 0 ;
83
+ for await ( const item of cacache . ls . stream ( cacheFileName ) ) {
84
+ try {
84
85
totalCount += 1 ;
85
86
const cachedItem = item as unknown as cacache . CacheObject ;
86
87
const res = await cacache . get ( cacheFileName , cachedItem . key ) ;
@@ -99,12 +100,17 @@ export async function cleanup(): Promise<void> {
99
100
await cacache . rm . content ( cacheFileName , cachedItem . integrity ) ;
100
101
deletedCount += 1 ;
101
102
}
103
+ } catch ( err ) /* istanbul ignore next */ {
104
+ logger . trace ( { err } , 'Error cleaning up cache entry' ) ;
105
+ errorCount += 1 ;
102
106
}
103
- const durationMs = Math . round ( Date . now ( ) - startTime ) ;
104
- logger . debug (
105
- `Deleted ${ deletedCount } of ${ totalCount } file cached entries in ${ durationMs } ms` ,
106
- ) ;
107
- } catch ( err ) /* istanbul ignore next */ {
108
- logger . warn ( { err } , 'Error cleaning up expired file cache' ) ;
109
107
}
108
+ // istanbul ignore if: cannot reproduce error
109
+ if ( errorCount > 0 ) {
110
+ logger . debug ( `Error count cleaning up cache: ${ errorCount } ` ) ;
111
+ }
112
+ const durationMs = Math . round ( Date . now ( ) - startTime ) ;
113
+ logger . debug (
114
+ `Deleted ${ deletedCount } of ${ totalCount } file cached entries in ${ durationMs } ms` ,
115
+ ) ;
110
116
}
0 commit comments