From 64381cca6a1a5e1e163b9e45be1200dd2ef10db2 Mon Sep 17 00:00:00 2001 From: Bethany Date: Mon, 19 Dec 2022 12:56:28 -0500 Subject: [PATCH] Re-add file size check prior to reading file (#2321) (#2330) * Re-add file size check prior to reading file * Remove redundant file size check --- src/Runner.Worker/FileCommandManager.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Runner.Worker/FileCommandManager.cs b/src/Runner.Worker/FileCommandManager.cs index 600db078a..a4eb2e676 100644 --- a/src/Runner.Worker/FileCommandManager.cs +++ b/src/Runner.Worker/FileCommandManager.cs @@ -182,6 +182,14 @@ namespace GitHub.Runner.Worker return; } + if (fileSize > AttachmentSizeLimit) + { + context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, AttachmentSizeLimit / 1024, fileSize / 1024)); + Trace.Info($"Step Summary file ({filePath}) is too large ({fileSize} bytes); skipping attachment upload"); + + return; + } + Trace.Verbose($"Step Summary file exists: {filePath} and has a file size of {fileSize} bytes"); var scrubbedFilePath = filePath + "-scrubbed"; @@ -210,14 +218,6 @@ namespace GitHub.Runner.Worker } else { - if (fileSize > AttachmentSizeLimit) - { - context.Error(String.Format(Constants.Runner.UnsupportedSummarySize, AttachmentSizeLimit / 1024, fileSize / 1024)); - Trace.Info($"Step Summary file ({filePath}) is too large ({fileSize} bytes); skipping attachment upload"); - - return; - } - Trace.Info($"Queueing file ({filePath}) for attachment upload ({attachmentName})"); // Attachments must be added to the parent context (job), not the current context (step) context.Root.QueueAttachFile(ChecksAttachmentType.StepSummary, attachmentName, scrubbedFilePath);