File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
roles/lib/files/FWO.Report Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change 1313using PdfSharp . Drawing ;
1414using PdfSharp . Pdf . IO ;
1515using FWO . Report . Data ;
16+ using FWO . Logging ;
1617
1718namespace 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
You can’t perform that action at this time.
0 commit comments