Skip to content

Commit 2b8a729

Browse files
[~] Working state?
1 parent 9ed360a commit 2b8a729

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

roles/lib/files/FWO.Report/ReportBase.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using PdfSharp.Drawing;
1414
using PdfSharp.Pdf.IO;
1515
using FWO.Report.Data;
16+
using FWO.Logging;
1617

1718
namespace FWO.Report
1819
{
@@ -234,26 +235,35 @@ public static string ToUtcString(string? timestring)
234235
OperatingSystem? os = Environment.OSVersion;
235236

236237
string path = "";
237-
BrowserFetcher? browserFetcher;
238+
Platform platform = Platform.Unknown;
239+
const SupportedBrowser wantedBrowser = SupportedBrowser.Chrome;
238240

239241
switch (os.Platform)
240242
{
241243
case PlatformID.Win32NT:
242-
browserFetcher = new();
244+
platform = Platform.Win32;
243245
break;
244246
case PlatformID.Unix:
245247
path = ChromeBinPathLinux;
246-
browserFetcher = new(new BrowserFetcherOptions { Path = path, Platform = Platform.Linux, Browser = SupportedBrowser.Chrome });
248+
platform = Platform.Linux;
247249
break;
248250
default:
249-
return default;
251+
break;
252+
}
253+
254+
BrowserFetcher browserFetcher = new(new BrowserFetcherOptions() { Platform = platform, Browser = wantedBrowser, Path = path });
255+
256+
InstalledBrowser? installedBrowser = browserFetcher.GetInstalledBrowsers()
257+
.FirstOrDefault(_ => _.Platform == platform && _.Browser == wantedBrowser);
258+
259+
if (installedBrowser == null)
260+
{
261+
throw new Exception($"Browser {wantedBrowser} is not installed!");
250262
}
251263

252-
InstalledBrowser? brw = browserFetcher.GetInstalledBrowsers().FirstOrDefault() ?? await browserFetcher.DownloadAsync(BrowserTag.Latest);
253-
254264
using IBrowser? browser = await Puppeteer.LaunchAsync(new LaunchOptions
255265
{
256-
ExecutablePath = path,
266+
ExecutablePath = installedBrowser.GetExecutablePath(),
257267
Headless = true
258268
});
259269

0 commit comments

Comments
 (0)