From 9d6767c39969ba1bdfbe708bdd6963db22bbbd71 Mon Sep 17 00:00:00 2001 From: Zoran Regvart Date: Tue, 14 Dec 2021 21:50:50 +0100 Subject: [PATCH] fix: drop support for named pipes on Windows (#962) Seems that folk are having issues with uploading 0-byte files from Windows agents. This effectively removes the support for Windows for uploading from named files that, due to `isFIFO` returning `false` on Windows for named pipes created using MSYS2's `mkfifo` command, resorted to checking if the file size is 0 - a common trait of named pipes. See https://github.com/actions/upload-artifact/issues/281 --- __tests__/test-artifact-file.sh | 6 ++++-- __tests__/upload.test.ts | 5 ++++- src/internal/upload-http-client.ts | 5 +---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/__tests__/test-artifact-file.sh b/__tests__/test-artifact-file.sh index 708dc80..d36d22e 100755 --- a/__tests__/test-artifact-file.sh +++ b/__tests__/test-artifact-file.sh @@ -18,8 +18,10 @@ if [ ! -f "$path" ]; then exit 1 fi -actualContent=$(cat $path) -if [ "$actualContent" != "$expectedContent" ];then +actualContent=$(cat "$path") +if [ "$expectedContent" == "_EMPTY_" ] && [ ! -s "$path" ]; then + exit 0 +elif [ "$actualContent" != "$expectedContent" ]; then echo "File contents are not correct, expected $expectedContent, received $actualContent" exit 1 fi \ No newline at end of file diff --git a/__tests__/upload.test.ts b/__tests__/upload.test.ts index 9f3ce1a..75c228e 100644 --- a/__tests__/upload.test.ts +++ b/__tests__/upload.test.ts @@ -181,7 +181,10 @@ describe('Upload Tests', () => { function hasMkfifo(): boolean { try { // make sure we drain the stdout - return execSync('which mkfifo').toString().length > 0 + return ( + process.platform !== 'win32' && + execSync('which mkfifo').toString().length > 0 + ) } catch (e) { return false } diff --git a/src/internal/upload-http-client.ts b/src/internal/upload-http-client.ts index 473f40d..9892a42 100644 --- a/src/internal/upload-http-client.ts +++ b/src/internal/upload-http-client.ts @@ -221,10 +221,7 @@ export class UploadHttpClient { ): Promise { const fileStat: fs.Stats = await stat(parameters.file) const totalFileSize = fileStat.size - // on Windows with mkfifo from MSYS2 stats.isFIFO returns false, so we check if running on Windows node and - // if the file has size of 0 to compensate - const isFIFO = - fileStat.isFIFO() || (process.platform === 'win32' && totalFileSize === 0) + const isFIFO = fileStat.isFIFO() let offset = 0 let isUploadSuccessful = true let failedChunkSizes = 0