From cc9ec0424eff1086e7330f9115aecdff2aef9f95 Mon Sep 17 00:00:00 2001 From: Ferenc Hammerl Date: Wed, 14 Dec 2022 01:17:17 +0100 Subject: [PATCH] Test out checking for fileexists in rmFile --- packages/artifact/src/internal/utils.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/artifact/src/internal/utils.ts b/packages/artifact/src/internal/utils.ts index cb5a9224..2de06d62 100644 --- a/packages/artifact/src/internal/utils.ts +++ b/packages/artifact/src/internal/utils.ts @@ -1,9 +1,9 @@ import crypto from 'crypto' -import {promises as fs} from 'fs' -import {IncomingHttpHeaders, OutgoingHttpHeaders} from 'http' -import {debug, info, warning} from '@actions/core' -import {HttpCodes, HttpClient, HttpClientResponse} from '@actions/http-client' -import {BearerCredentialHandler} from '@actions/http-client/lib/auth' +import { promises as fs } from 'fs' +import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http' +import { debug, info, warning } from '@actions/core' +import { HttpCodes, HttpClient, HttpClientResponse } from '@actions/http-client' +import { BearerCredentialHandler } from '@actions/http-client/lib/auth' import { getRuntimeToken, getRuntimeUrl, @@ -270,6 +270,16 @@ export async function getFileSize(filePath: string): Promise { } export async function rmFile(filePath: string): Promise { + // TODO: find actual fix + // node 16 `CreateWriteStream` no longer creates a file + // download-http-client.ts#L151 no longer creates a file and we fail here + try { + await fs.stat(filePath) + } + catch (e) { + console.log("File does not exist."); + return; + } await fs.unlink(filePath) }