Skip to content

Commit

Permalink
fix: ensure storage directory exists before accessing database
Browse files Browse the repository at this point in the history
  • Loading branch information
Elagoht committed Dec 21, 2024
1 parent b8c5e61 commit a601960
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/DataAccess/DataBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public Database(string username)
{
try
{
if (!Directory.Exists(OperatingSystem.StoragePath))
Directory.CreateDirectory(OperatingSystem.StoragePath);

databaseFile = Path.Combine(
OperatingSystem.StoragePath,
$"{username}.bus"
Expand Down Expand Up @@ -108,7 +111,7 @@ public List<ListableDatabaseEntry> FetchAll() =>
).ToList();

public DatabaseEntry Fetch(string id) =>
database.Entries.Find(entry => entry.Id == id);
database.Entries.Find(entry => entry.Id == id);

public List<ListableDatabaseEntry> Query(string keyword) =>
database.Entries.Where(entry =>
Expand Down

0 comments on commit a601960

Please sign in to comment.