Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
(GH-97) Warn user if total file sizes is above 20MB
Browse files Browse the repository at this point in the history
fixes #97
  • Loading branch information
AdmiringWorm committed Feb 1, 2020
1 parent 9b557a3 commit 5ee6a93
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/Codecov/Program/UploadFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Codecov.Terminal;
using Codecov.Upload;
using Codecov.Url;
using Codecov.Utilities;
using Codecov.Yaml;

namespace Codecov.Program
Expand Down Expand Up @@ -112,6 +113,14 @@ public void Uploader()
return;
}

// We warn if the total file size is above 20 MB
var fileSizes = Coverage.CoverageReports.Sum(x => FileSystem.GetFileSize(x.File));
if (fileSizes > 20_971_520)
{
Log.Warning($"Total file size of reports is above 20MB, this may prevent report being shown on {Url.GetUrl.Host}");
Log.Warning("Reduce the total upload size if this occurs");
}

Log.Information("Uploading Reports.");
Log.Information($"url: {Url.GetUrl.Scheme}://{Url.GetUrl.Authority}");
Log.Verboase($"api endpoint: {Url.GetUrl}");
Expand Down
6 changes: 6 additions & 0 deletions Source/Codecov/Utilities/FileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ namespace Codecov.Utilities
{
internal static class FileSystem
{
internal static long GetFileSize(string path)
{
var fileInfo = new FileInfo(path);
return fileInfo.Exists ? fileInfo.Length : 0;
}

internal static string NormalizedPath(string path)
{
if (string.IsNullOrWhiteSpace(path))
Expand Down

0 comments on commit 5ee6a93

Please sign in to comment.