From 5ee6a93a283e37dbfd81260760bc68ae29e7b215 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Sat, 1 Feb 2020 09:28:50 +0100 Subject: [PATCH] (GH-97) Warn user if total file sizes is above 20MB fixes #97 --- Source/Codecov/Program/UploadFacade.cs | 9 +++++++++ Source/Codecov/Utilities/FileSystem.cs | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Source/Codecov/Program/UploadFacade.cs b/Source/Codecov/Program/UploadFacade.cs index 56bbf90..d8c0bde 100644 --- a/Source/Codecov/Program/UploadFacade.cs +++ b/Source/Codecov/Program/UploadFacade.cs @@ -14,6 +14,7 @@ using Codecov.Terminal; using Codecov.Upload; using Codecov.Url; +using Codecov.Utilities; using Codecov.Yaml; namespace Codecov.Program @@ -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}"); diff --git a/Source/Codecov/Utilities/FileSystem.cs b/Source/Codecov/Utilities/FileSystem.cs index 9d43e62..70a00cb 100644 --- a/Source/Codecov/Utilities/FileSystem.cs +++ b/Source/Codecov/Utilities/FileSystem.cs @@ -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))