mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Core - Prevent double-shutdowns which can cause crashes
Storage - Make the DbContext factory thread safe Workshop - Replaced pagination with infinite scroll Workshop - Added supported platforms and admin requirements to plugin details page
This commit is contained in:
1 parent
7e981a61d3
commit
da3d47d7b8
27 files changed
+491
-331
No files matched your search
@@ -9,6 +9,7 @@ public static class StorageManager
|
||||
{
|
||||
private static bool _ranMigrations;
|
||||
private static bool _inUse;
|
||||
private static object _factoryLock = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a backup of the database if the last backup is older than 10 minutes
|
||||
@@ -39,19 +40,22 @@ public static class StorageManager
|
||||
|
||||
File.Copy(database, Path.Combine(backupFolder, $"artemis-{DateTime.Now:yyyy-dd-M--HH-mm-ss}.db"));
|
||||
}
|
||||
|
||||
|
||||
public static ArtemisDbContext CreateDbContext(string dataFolder)
|
||||
{
|
||||
_inUse = true;
|
||||
lock (_factoryLock)
|
||||
{
|
||||
_inUse = true;
|
||||
|
||||
ArtemisDbContext dbContext = new() {DataFolder = dataFolder};
|
||||
if (_ranMigrations)
|
||||
return dbContext;
|
||||
|
||||
dbContext.Database.Migrate();
|
||||
dbContext.Database.ExecuteSqlRaw("PRAGMA optimize");
|
||||
_ranMigrations = true;
|
||||
|
||||
ArtemisDbContext dbContext = new() {DataFolder = dataFolder};
|
||||
if (_ranMigrations)
|
||||
return dbContext;
|
||||
|
||||
dbContext.Database.Migrate();
|
||||
dbContext.Database.ExecuteSqlRaw("PRAGMA optimize");
|
||||
_ranMigrations = true;
|
||||
|
||||
return dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user