Skip to content

Commit

Permalink
[Bot -> Settings] Remove data directory constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogFeelings committed Apr 14, 2024
1 parent 68d4e6c commit 0e997f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Source/SammBot.Bot/Database/BotDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
using JetBrains.Annotations;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using SammBot.Bot.Settings;
using SammBot.Library.Models.Database;
using System.IO;
using SammBot.Library;

namespace SammBot.Bot.Database;

Expand All @@ -46,7 +46,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string databaseFile = Path.Combine(SettingsManager.Instance.BotDataDirectory, "bot.db");
string databaseFile = Path.Combine(Constants.BotDataDirectory, "bot.db");

SqliteConnectionStringBuilder connectionStringBuilder = new SqliteConnectionStringBuilder() { DataSource = databaseFile };
SqliteConnection connection = new SqliteConnection(connectionStringBuilder.ToString());
Expand Down
2 changes: 1 addition & 1 deletion Source/SammBot.Bot/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private MatchaLogger InitializeLogger()
FileSinkConfig fileConfig = new FileSinkConfig()
{
SeverityFilterLevel = filterLevel,
FilePath = Path.Combine(SettingsManager.Instance.BotDataDirectory, "Logs")
FilePath = Path.Combine(Constants.BotDataDirectory, "Logs")
};

ConsoleSink consoleSink = new ConsoleSink()
Expand Down
4 changes: 2 additions & 2 deletions Source/SammBot.Bot/SammBot.Bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Company>Analog Feelings</Company>
<Product>Samm-Bot</Product>
<AssemblyVersion>8.0</AssemblyVersion>
<FileVersion>8.0</FileVersion>
<AssemblyVersion>9.0</AssemblyVersion>
<FileVersion>9.0</FileVersion>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
13 changes: 2 additions & 11 deletions Source/SammBot.Bot/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,13 @@ public class SettingsManager
{
public BotConfig LoadedConfig = new BotConfig();

public readonly string BotDataDirectory;

private SettingsManager()
{
string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

BotDataDirectory = Path.Combine(appData, Constants.BOT_NAME);
}

public bool LoadConfiguration()
{
string configFilePath = Path.Combine(BotDataDirectory, Constants.CONFIG_FILE);
string configFilePath = Path.Combine(Constants.BotDataDirectory, Constants.CONFIG_FILE);

try
{
Directory.CreateDirectory(BotDataDirectory);
Directory.CreateDirectory(Constants.BotDataDirectory);

if (!File.Exists(configFilePath)) return false;
}
Expand Down

0 comments on commit 0e997f4

Please sign in to comment.