performance optimizations
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using MareSynchronos.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
#nullable disable
|
||||
@@ -12,22 +11,6 @@ namespace MareSynchronos.FileCacheDB
|
||||
public FileCacheContext()
|
||||
{
|
||||
DbPath = Path.Combine(Plugin.PluginInterface.ConfigDirectory.FullName, "FileCache.db");
|
||||
string oldDbPath = Path.Combine(Plugin.PluginInterface.ConfigDirectory.FullName, "FileCacheDebug.db");
|
||||
if (!Directory.Exists(Plugin.PluginInterface.ConfigDirectory.FullName))
|
||||
{
|
||||
Directory.CreateDirectory(Plugin.PluginInterface.ConfigDirectory.FullName);
|
||||
}
|
||||
var veryOldDbPath = Path.Combine(Plugin.PluginInterface.ConfigDirectory.FullName, "..", "FileCacheDebug.db");
|
||||
if (File.Exists(veryOldDbPath))
|
||||
{
|
||||
Logger.Debug("Migrated old path to new path");
|
||||
File.Move(veryOldDbPath, oldDbPath, true);
|
||||
}
|
||||
if (File.Exists(oldDbPath))
|
||||
{
|
||||
File.Move(oldDbPath, DbPath, true);
|
||||
}
|
||||
|
||||
Database.EnsureCreated();
|
||||
}
|
||||
|
||||
@@ -42,7 +25,7 @@ namespace MareSynchronos.FileCacheDB
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlite("Data Source=" + DbPath);
|
||||
optionsBuilder.UseSqlite("Data Source=" + DbPath+";Cache=Shared");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +36,6 @@ namespace MareSynchronos.FileCacheDB
|
||||
entity.HasKey(e => new { e.Hash, e.Filepath });
|
||||
|
||||
entity.ToTable("FileCache");
|
||||
|
||||
entity.Property(c => c.Version).HasDefaultValue(0).IsRowVersion();
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
|
||||
Reference in New Issue
Block a user