Use the AppContext API as it's reccommended (just best practises)

This commit is contained in:
tidusjar 2021-03-01 08:33:08 +00:00
commit 36af39ebca

View file

@ -251,12 +251,12 @@ namespace Ombi
if (setBaseUrl) if (setBaseUrl)
{ {
var trimmedBaseUrl = baseUrl.EndsWith('/') ? baseUrl.TrimEnd('/') : baseUrl; var trimmedBaseUrl = baseUrl.EndsWith('/') ? baseUrl.TrimEnd('/') : baseUrl;
var process = Process.GetCurrentProcess().MainModule.FileName; var process = AppContext.BaseDirectory;
var ombiInstalledDir = Path.GetDirectoryName(process); var ombiInstalledDir = Path.GetDirectoryName(process);
var indexPath = Path.Combine(ombiInstalledDir, "ClientApp", "dist", "index.html"); var indexPath = Path.Combine(ombiInstalledDir, "ClientApp", "dist", "index.html");
if (!File.Exists(indexPath)) if (!File.Exists(indexPath))
{ {
var error = $"Can't set the base URL because we cannot find the file at {indexPath}, if you are trying to set a base url please report this on Github!"; var error = $"Can't set the base URL because we cannot find the file at '{indexPath}', if you are trying to set a base url please report this on Github!";
Console.WriteLine(error); Console.WriteLine(error);
throw new Exception(error); throw new Exception(error);
} }