Set the CommandTimeout longer to see if EF can get a handle on the SQLite file when it's locked #2750

This commit is contained in:
tidusjar 2019-02-25 21:36:19 +00:00
commit c8415f8da9
4 changed files with 12 additions and 25 deletions

View file

@ -13,6 +13,7 @@ namespace Ombi.Store.Context
if (_created) return; if (_created) return;
_created = true; _created = true;
Database.SetCommandTimeout(60);
Database.Migrate(); Database.Migrate();
} }

View file

@ -18,6 +18,7 @@ namespace Ombi.Store.Context
if (_created) return; if (_created) return;
_created = true; _created = true;
Database.SetCommandTimeout(60);
Database.Migrate(); Database.Migrate();
} }
@ -107,6 +108,7 @@ namespace Ombi.Store.Context
var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast<NotificationAgent>().ToList(); var allAgents = Enum.GetValues(typeof(NotificationAgent)).Cast<NotificationAgent>().ToList();
var allTypes = Enum.GetValues(typeof(NotificationType)).Cast<NotificationType>().ToList(); var allTypes = Enum.GetValues(typeof(NotificationType)).Cast<NotificationType>().ToList();
var needToSave = false;
foreach (var agent in allAgents) foreach (var agent in allAgents)
{ {
foreach (var notificationType in allTypes) foreach (var notificationType in allTypes)
@ -116,6 +118,8 @@ namespace Ombi.Store.Context
// We already have this // We already have this
continue; continue;
} }
needToSave = true;
NotificationTemplates notificationToAdd; NotificationTemplates notificationToAdd;
switch (notificationType) switch (notificationType)
{ {
@ -230,7 +234,11 @@ namespace Ombi.Store.Context
NotificationTemplates.Add(notificationToAdd); NotificationTemplates.Add(notificationToAdd);
} }
} }
SaveChanges();
if (needToSave)
{
SaveChanges();
}
} }
} }
} }

View file

@ -14,6 +14,7 @@ namespace Ombi.Store.Context
if (_created) return; if (_created) return;
_created = true; _created = true;
Database.SetCommandTimeout(60);
Database.Migrate(); Database.Migrate();
} }
@ -63,13 +64,6 @@ namespace Ombi.Store.Context
}); });
SaveChanges(); SaveChanges();
} }
SaveChanges();
}
~SettingsContext()
{
} }
} }
} }

View file

@ -91,9 +91,7 @@ namespace Ombi
dbBaseUrl.Value = baseUrl; dbBaseUrl.Value = baseUrl;
ctx.SaveChanges(); ctx.SaveChanges();
} }
DeleteSchedulesDb();
Console.WriteLine($"We are running on {urlValue}"); Console.WriteLine($"We are running on {urlValue}");
CreateWebHostBuilder(args).Build().Run(); CreateWebHostBuilder(args).Build().Run();
@ -226,20 +224,6 @@ namespace Ombi
} }
} }
private static void DeleteSchedulesDb()
{
try
{
if (File.Exists("Schedules.db"))
{
File.Delete("Schedules.db");
}
}
catch (Exception)
{
}
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args) WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>() .UseStartup<Startup>()