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
This commit is contained in:
Bethany
2022-12-19 12:56:28 -05:00
committed by GitHub
parent f1b1532f32
commit 64381cca6a

View File

@@ -182,6 +182,14 @@ namespace GitHub.Runner.Worker
return; 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"); Trace.Verbose($"Step Summary file exists: {filePath} and has a file size of {fileSize} bytes");
var scrubbedFilePath = filePath + "-scrubbed"; var scrubbedFilePath = filePath + "-scrubbed";
@@ -210,14 +218,6 @@ namespace GitHub.Runner.Worker
} }
else 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})"); Trace.Info($"Queueing file ({filePath}) for attachment upload ({attachmentName})");
// Attachments must be added to the parent context (job), not the current context (step) // Attachments must be added to the parent context (job), not the current context (step)
context.Root.QueueAttachFile(ChecksAttachmentType.StepSummary, attachmentName, scrubbedFilePath); context.Root.QueueAttachFile(ChecksAttachmentType.StepSummary, attachmentName, scrubbedFilePath);