@@ -4,7 +4,6 @@ import * as path from "path";
44import { performance } from "perf_hooks" ;
55
66import * as toolcache from "@actions/tool-cache" ;
7- import del from "del" ;
87import { default as deepEqual } from "fast-deep-equal" ;
98import * as semver from "semver" ;
109import { v4 as uuidV4 } from "uuid" ;
@@ -24,7 +23,7 @@ import {
2423import { Logger } from "./logging" ;
2524import * as tar from "./tar" ;
2625import * as util from "./util" ;
27- import { isGoodVersion } from "./util" ;
26+ import { cleanUpGlob , isGoodVersion } from "./util" ;
2827
2928export enum ToolsSource {
3029 Unknown = "UNKNOWN" ,
@@ -550,18 +549,25 @@ export const downloadCodeQL = async function (
550549 `Finished downloading CodeQL bundle to ${ archivedBundlePath } (${ downloadDurationMs } ms).` ,
551550 ) ;
552551
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+ }
565571
566572 const bundleVersion =
567573 maybeBundleVersion ?? tryGetBundleVersionFromUrl ( codeqlURL , logger ) ;
@@ -765,6 +771,7 @@ async function setupCodeQLBundleWithCompressionMethod(
765771 source . codeqlTarPath ,
766772 compressionMethod ,
767773 zstdAvailability . version ,
774+ logger ,
768775 ) ;
769776 toolsSource = ToolsSource . Local ;
770777 break ;
@@ -802,24 +809,6 @@ async function setupCodeQLBundleWithCompressionMethod(
802809 } ;
803810}
804811
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-
823812function sanitizeUrlForStatusReport ( url : string ) : string {
824813 return [ "github/codeql-action" , "dsp-testing/codeql-cli-nightlies" ] . some (
825814 ( repo ) => url . startsWith ( `https://github.com/${ repo } /releases/download/` ) ,
0 commit comments