diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index f2ee6effb9..8905c91b92 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -83,7 +83,7 @@ namespace osu.Game protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); - //private OsuDbContext dbContext; + private OsuDbContext dbContext; private OsuDbContext createDbContext() { @@ -96,6 +96,7 @@ namespace osu.Game command.CommandText = "PRAGMA journal_mode=WAL;"; command.ExecuteNonQuery(); } + context.Database.SetCommandTimeout(new TimeSpan(TimeSpan.TicksPerSecond * 10)); return context; } @@ -105,8 +106,7 @@ namespace osu.Game dependencies.Cache(this); dependencies.Cache(LocalConfig); - - using (var dbContext = createDbContext()) + dbContext = createDbContext(); if (dbContext.Database.GetPendingMigrations().Any()) dbContext.Database.Migrate(); @@ -116,11 +116,11 @@ namespace osu.Game Token = LocalConfig.Get(OsuSetting.Token) }); - dependencies.Cache(RulesetStore = new RulesetStore(createDbContext())); - dependencies.Cache(FileStore = new FileStore(createDbContext(), Host.Storage)); - dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, createDbContext(), RulesetStore, API, Host)); - dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, createDbContext(), Host, BeatmapManager, RulesetStore)); - dependencies.Cache(KeyBindingStore = new KeyBindingStore(createDbContext(), RulesetStore)); + dependencies.Cache(RulesetStore = new RulesetStore(dbContext)); + dependencies.Cache(FileStore = new FileStore(dbContext, Host.Storage)); + dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, dbContext, RulesetStore, API, Host)); + dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, dbContext, Host, BeatmapManager, RulesetStore)); + dependencies.Cache(KeyBindingStore = new KeyBindingStore(dbContext, RulesetStore)); dependencies.Cache(new OsuColour()); //this completely overrides the framework default. will need to change once we make a proper FontStore. @@ -247,7 +247,7 @@ namespace osu.Game LocalConfig.Save(); } - //dbContext?.Dispose(); + dbContext?.Dispose(); base.Dispose(isDisposing); }