From 396e5c9215d6ab7c306bf4ae0f23c61353bac423 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 1 Aug 2018 21:09:22 -0500 Subject: [PATCH] confirmed working for linux fixed the database access issue --- Application/Server.cs | 2 +- SharedLibraryCore/Database/DatabaseContext.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Application/Server.cs b/Application/Server.cs index 83c4a2c5c..830332d78 100644 --- a/Application/Server.cs +++ b/Application/Server.cs @@ -802,7 +802,7 @@ namespace IW4MAdmin // hopefully fix wine drive name mangling if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - logPath = Regex.Replace(logPath, @"[A-Z]:", ""); + logPath = Regex.Replace($"{Path.DirectorySeparatorChar}{logPath}", @"[A-Z]:", ""); } if (!File.Exists(logPath)) diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs index c50bcaf1c..f04550e01 100644 --- a/SharedLibraryCore/Database/DatabaseContext.cs +++ b/SharedLibraryCore/Database/DatabaseContext.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Data.Sqlite; using SharedLibraryCore.Interfaces; +using System.Runtime.InteropServices; namespace SharedLibraryCore.Database { @@ -37,6 +38,10 @@ namespace SharedLibraryCore.Database if (string.IsNullOrEmpty(_ConnectionString)) { string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); + // allows the application to find the database file + currentPath = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? + $"{Path.DirectorySeparatorChar}{currentPath}" : + currentPath; var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = $"{currentPath}{Path.DirectorySeparatorChar}Database.db".Substring(6) }; var connectionString = connectionStringBuilder.ToString(); var connection = new SqliteConnection(connectionString);