@@ -7,7 +7,7 @@ import type { Config } from "./config-utils";
77import type { FileSystem } from "./fs" ;
88import { Language } from "./languages" ;
99import { getActionsLogger , type Logger } from "./logging" ;
10- import { getCodeQLDatabasePath } from "./util" ;
10+ import { getCodeQLDatabasePath , getErrorMessage } from "./util" ;
1111
1212/**
1313 * Known tags for diagnostics. There is currently only "internal-error",
@@ -304,6 +304,7 @@ export function flushDiagnostics(
304304 `Moving ${ diagnosticsCount } diagnostic(s) to their respective databases.` ,
305305 ) ;
306306
307+ const failedFlushDiagnostics : TemporaryDiagnostic [ ] = [ ] ;
307308 for ( const temporary of temporaryDiagnostics ) {
308309 // If `temporary.language` is `undefined`, then we didn't have a `config` at the time that
309310 // `addNoLanguageDiagnostic` was called. In that case, we arbitrarily choose the first
@@ -315,11 +316,20 @@ export function flushDiagnostics(
315316 const filename = path . basename ( temporary . path ) ;
316317 const destination = path . join ( directory , filename ) ;
317318
318- action . fs . renameSync ( temporary . path , destination ) ;
319+ try {
320+ action . fs . mkdirSync ( directory , { recursive : true } ) ;
321+ action . fs . renameSync ( temporary . path , destination ) ;
322+ } catch ( err ) {
323+ action . logger . warning (
324+ `Failed to rename '${ temporary . path } ' to '${ destination } ': ${ getErrorMessage ( err ) } ` ,
325+ ) ;
326+
327+ failedFlushDiagnostics . push ( temporary ) ;
328+ }
319329 }
320330
321331 // Reset the temporary diagnostics arrays.
322- temporaryDiagnostics = [ ] ;
332+ temporaryDiagnostics = failedFlushDiagnostics ;
323333}
324334
325335/**
0 commit comments