@@ -4,7 +4,6 @@ import * as path from "path";
4
4
import { performance } from "perf_hooks" ;
5
5
6
6
import * as toolcache from "@actions/tool-cache" ;
7
- import del from "del" ;
8
7
import { default as deepEqual } from "fast-deep-equal" ;
9
8
import * as semver from "semver" ;
10
9
import { v4 as uuidV4 } from "uuid" ;
@@ -24,7 +23,7 @@ import {
24
23
import { Logger } from "./logging" ;
25
24
import * as tar from "./tar" ;
26
25
import * as util from "./util" ;
27
- import { isGoodVersion } from "./util" ;
26
+ import { cleanUpGlob , isGoodVersion } from "./util" ;
28
27
29
28
export enum ToolsSource {
30
29
Unknown = "UNKNOWN" ,
@@ -550,18 +549,25 @@ export const downloadCodeQL = async function (
550
549
`Finished downloading CodeQL bundle to ${ archivedBundlePath } (${ downloadDurationMs } ms).` ,
551
550
) ;
552
551
553
- logger . debug ( "Extracting CodeQL bundle." ) ;
554
- const extractionStart = performance . now ( ) ;
555
- const extractedBundlePath = await tar . extract (
556
- archivedBundlePath ,
557
- compressionMethod ,
558
- tarVersion ,
559
- ) ;
560
- const extractionDurationMs = Math . round ( performance . now ( ) - extractionStart ) ;
561
- logger . debug (
562
- `Finished extracting CodeQL bundle to ${ extractedBundlePath } (${ extractionDurationMs } ms).` ,
563
- ) ;
564
- await cleanUpGlob ( archivedBundlePath , "CodeQL bundle archive" , logger ) ;
552
+ let extractedBundlePath : string ;
553
+ let extractionDurationMs : number ;
554
+
555
+ try {
556
+ logger . debug ( "Extracting CodeQL bundle." ) ;
557
+ const extractionStart = performance . now ( ) ;
558
+ extractedBundlePath = await tar . extract (
559
+ archivedBundlePath ,
560
+ compressionMethod ,
561
+ tarVersion ,
562
+ logger ,
563
+ ) ;
564
+ extractionDurationMs = Math . round ( performance . now ( ) - extractionStart ) ;
565
+ logger . debug (
566
+ `Finished extracting CodeQL bundle to ${ extractedBundlePath } (${ extractionDurationMs } ms).` ,
567
+ ) ;
568
+ } finally {
569
+ await cleanUpGlob ( archivedBundlePath , "CodeQL bundle archive" , logger ) ;
570
+ }
565
571
566
572
const bundleVersion =
567
573
maybeBundleVersion ?? tryGetBundleVersionFromUrl ( codeqlURL , logger ) ;
@@ -765,6 +771,7 @@ async function setupCodeQLBundleWithCompressionMethod(
765
771
source . codeqlTarPath ,
766
772
compressionMethod ,
767
773
zstdAvailability . version ,
774
+ logger ,
768
775
) ;
769
776
toolsSource = ToolsSource . Local ;
770
777
break ;
@@ -802,24 +809,6 @@ async function setupCodeQLBundleWithCompressionMethod(
802
809
} ;
803
810
}
804
811
805
- async function cleanUpGlob ( glob : string , name : string , logger : Logger ) {
806
- logger . debug ( `Cleaning up ${ name } .` ) ;
807
- try {
808
- const deletedPaths = await del ( glob , { force : true } ) ;
809
- if ( deletedPaths . length === 0 ) {
810
- logger . warning (
811
- `Failed to clean up ${ name } : no files found matching ${ glob } .` ,
812
- ) ;
813
- } else if ( deletedPaths . length === 1 ) {
814
- logger . debug ( `Cleaned up ${ name } .` ) ;
815
- } else {
816
- logger . debug ( `Cleaned up ${ name } (${ deletedPaths . length } files).` ) ;
817
- }
818
- } catch ( e ) {
819
- logger . warning ( `Failed to clean up ${ name } : ${ e } .` ) ;
820
- }
821
- }
822
-
823
812
function sanitizeUrlForStatusReport ( url : string ) : string {
824
813
return [ "github/codeql-action" , "dsp-testing/codeql-cli-nightlies" ] . some (
825
814
( repo ) => url . startsWith ( `https://github.com/${ repo } /releases/download/` ) ,
0 commit comments