diff --git a/osu.Game.Tests/Database/BeatmapImporterTests.cs b/osu.Game.Tests/Database/BeatmapImporterTests.cs index b7bfe14402..00276955aa 100644 --- a/osu.Game.Tests/Database/BeatmapImporterTests.cs +++ b/osu.Game.Tests/Database/BeatmapImporterTests.cs @@ -507,7 +507,7 @@ namespace osu.Game.Tests.Database using (var stream = storage.GetStream(firstFile.File.GetStoragePath())) originalLength = stream.Length; - using (var stream = storage.GetStream(firstFile.File.GetStoragePath(), FileAccess.Write, FileMode.Create)) + using (var stream = storage.CreateFileSafely(firstFile.File.GetStoragePath())) stream.WriteByte(0); var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm); diff --git a/osu.Game.Tests/Visual/Navigation/TestEFToRealmMigration.cs b/osu.Game.Tests/Visual/Navigation/TestEFToRealmMigration.cs index 8498b9b28f..2ea768b878 100644 --- a/osu.Game.Tests/Visual/Navigation/TestEFToRealmMigration.cs +++ b/osu.Game.Tests/Visual/Navigation/TestEFToRealmMigration.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.IO; using System.Linq; using System.Runtime.InteropServices; using NUnit.Framework; @@ -25,7 +24,7 @@ namespace osu.Game.Tests.Visual.Navigation if (isDisposing) return; - using (var outStream = LocalStorage.GetStream(DatabaseContextFactory.DATABASE_NAME, FileAccess.Write, FileMode.Create)) + using (var outStream = LocalStorage.CreateFileSafely(DatabaseContextFactory.DATABASE_NAME)) using (var stream = TestResources.OpenResource(DatabaseContextFactory.DATABASE_NAME)) stream.CopyTo(outStream); } diff --git a/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs b/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs index 4c1256df2e..e5c539bbf1 100644 --- a/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/DataLoadTest.cs @@ -28,7 +28,7 @@ namespace osu.Game.Tournament.Tests.NonVisual // ReSharper disable once AccessToDisposedClosure var storage = host.Storage.GetStorageForDirectory(Path.Combine("tournaments", "default")); - using (var stream = storage.GetStream("bracket.json", FileAccess.Write, FileMode.Create)) + using (var stream = storage.CreateFileSafely("bracket.json")) using (var writer = new StreamWriter(stream)) { writer.Write(@"{ diff --git a/osu.Game.Tournament.Tests/Screens/TestSceneDrawingsScreen.cs b/osu.Game.Tournament.Tests/Screens/TestSceneDrawingsScreen.cs index e2954c8f10..0e38c777ba 100644 --- a/osu.Game.Tournament.Tests/Screens/TestSceneDrawingsScreen.cs +++ b/osu.Game.Tournament.Tests/Screens/TestSceneDrawingsScreen.cs @@ -15,7 +15,7 @@ namespace osu.Game.Tournament.Tests.Screens [BackgroundDependencyLoader] private void load(Storage storage) { - using (var stream = storage.GetStream("drawings.txt", FileAccess.Write)) + using (var stream = storage.CreateFileSafely("drawings.txt")) using (var writer = new StreamWriter(stream)) { writer.WriteLine("KR : South Korea : KOR"); diff --git a/osu.Game.Tournament/Models/StableInfo.cs b/osu.Game.Tournament/Models/StableInfo.cs index 1ebc81c773..c835b11a4d 100644 --- a/osu.Game.Tournament/Models/StableInfo.cs +++ b/osu.Game.Tournament/Models/StableInfo.cs @@ -45,7 +45,7 @@ namespace osu.Game.Tournament.Models public void SaveChanges() { - using (var stream = configStorage.GetStream(config_path, FileAccess.Write, FileMode.Create)) + using (var stream = configStorage.CreateFileSafely(config_path)) using (var sw = new StreamWriter(stream)) { sw.Write(JsonConvert.SerializeObject(this, diff --git a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs index d02e0ebf86..53ac93afea 100644 --- a/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs +++ b/osu.Game.Tournament/Screens/Drawings/DrawingsScreen.cs @@ -205,7 +205,7 @@ namespace osu.Game.Tournament.Screens.Drawings try { // Write to drawings_results - using (Stream stream = storage.GetStream(results_filename, FileAccess.Write, FileMode.Create)) + using (Stream stream = storage.CreateFileSafely(results_filename)) using (StreamWriter sw = new StreamWriter(stream)) { sw.Write(text); diff --git a/osu.Game.Tournament/TournamentGameBase.cs b/osu.Game.Tournament/TournamentGameBase.cs index a251a043f7..363baccb37 100644 --- a/osu.Game.Tournament/TournamentGameBase.cs +++ b/osu.Game.Tournament/TournamentGameBase.cs @@ -321,7 +321,7 @@ namespace osu.Game.Tournament Converters = new JsonConverter[] { new JsonPointConverter() } }); - using (var stream = storage.GetStream(BRACKET_FILENAME, FileAccess.Write, FileMode.Create)) + using (var stream = storage.CreateFileSafely(BRACKET_FILENAME)) using (var sw = new StreamWriter(stream)) sw.Write(serialisedLadder); } diff --git a/osu.Game/Database/LegacyExporter.cs b/osu.Game/Database/LegacyExporter.cs index ee960b6b30..992d1854e7 100644 --- a/osu.Game/Database/LegacyExporter.cs +++ b/osu.Game/Database/LegacyExporter.cs @@ -37,7 +37,7 @@ namespace osu.Game.Database { string filename = $"{item.GetDisplayString().GetValidArchiveContentFilename()}{FileExtension}"; - using (var stream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) + using (var stream = exportStorage.CreateFileSafely(filename)) ExportModelTo(item, stream); exportStorage.PresentFileExternally(filename); diff --git a/osu.Game/Database/RealmAccess.cs b/osu.Game/Database/RealmAccess.cs index 937876a70e..dbd3b96763 100644 --- a/osu.Game/Database/RealmAccess.cs +++ b/osu.Game/Database/RealmAccess.cs @@ -242,7 +242,7 @@ namespace osu.Game.Database storage.Delete(Filename); using (var inputStream = storage.GetStream(recoveryFilename)) - using (var outputStream = storage.GetStream(Filename, FileAccess.Write, FileMode.Create)) + using (var outputStream = storage.CreateFileSafely(Filename)) inputStream.CopyTo(outputStream); storage.Delete(recoveryFilename); diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index a2f1a3d7b9..1fc2633143 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -118,7 +118,7 @@ namespace osu.Game.Graphics if (filename == null) return; - using (var stream = storage.GetStream(filename, FileAccess.Write)) + using (var stream = storage.CreateFileSafely(filename)) { switch (screenshotFormat.Value) { diff --git a/osu.Game/IO/WrappedStorage.cs b/osu.Game/IO/WrappedStorage.cs index a6605de1d2..d4d9d531fa 100644 --- a/osu.Game/IO/WrappedStorage.cs +++ b/osu.Game/IO/WrappedStorage.cs @@ -67,9 +67,13 @@ namespace osu.Game.IO public override IEnumerable GetFiles(string path, string pattern = "*") => ToLocalRelative(UnderlyingStorage.GetFiles(MutatePath(path), pattern)); + public override Stream CreateFileSafely(string path) => UnderlyingStorage.CreateFileSafely(path); + public override Stream GetStream(string path, FileAccess access = FileAccess.Read, FileMode mode = FileMode.OpenOrCreate) => UnderlyingStorage.GetStream(MutatePath(path), access, mode); + public override void Move(string from, string to) => UnderlyingStorage.Move(from, to); + public override bool OpenFileExternally(string filename) => UnderlyingStorage.OpenFileExternally(MutatePath(filename)); public override bool PresentFileExternally(string filename) => UnderlyingStorage.PresentFileExternally(MutatePath(filename)); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 3d56d33689..785881d97a 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -1207,6 +1207,8 @@ namespace osu.Game Current = newScreen?.GetType().ReadableName(), Previous = current?.GetType().ReadableName(), }; + + scope.SetTag(@"screen", newScreen?.GetType().ReadableName() ?? @"none"); }); switch (newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 2e4758a134..564cb6c131 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -243,7 +243,7 @@ namespace osu.Game { if (source != null) { - using (var destination = Storage.GetStream(Path.Combine(backup_folder, $"collection.{migration}.db"), FileAccess.Write, FileMode.CreateNew)) + using (var destination = Storage.CreateFileSafely(Path.Combine(backup_folder, $"collection.{migration}.db"))) source.CopyTo(destination); } } diff --git a/osu.Game/Stores/RealmFileStore.cs b/osu.Game/Stores/RealmFileStore.cs index b5dd3d64e4..457d70f29a 100644 --- a/osu.Game/Stores/RealmFileStore.cs +++ b/osu.Game/Stores/RealmFileStore.cs @@ -65,7 +65,7 @@ namespace osu.Game.Stores { data.Seek(0, SeekOrigin.Begin); - using (var output = Storage.GetStream(file.GetStoragePath(), FileAccess.Write)) + using (var output = Storage.CreateFileSafely(file.GetStoragePath())) data.CopyTo(output); data.Seek(0, SeekOrigin.Begin); diff --git a/osu.Game/Utils/SentryLogger.cs b/osu.Game/Utils/SentryLogger.cs index 3edb27ca9b..5390c666ed 100644 --- a/osu.Game/Utils/SentryLogger.cs +++ b/osu.Game/Utils/SentryLogger.cs @@ -18,6 +18,7 @@ using osu.Game.Database; using osu.Game.Models; using osu.Game.Online.API.Requests.Responses; using osu.Game.Overlays; +using osu.Game.Rulesets; using osu.Game.Skinning; using Sentry; using Sentry.Protocol; @@ -109,6 +110,7 @@ namespace osu.Game.Utils }, scope => { var beatmap = game.Dependencies.Get>().Value.BeatmapInfo; + var ruleset = game.Dependencies.Get>().Value; scope.Contexts[@"config"] = new { @@ -125,6 +127,8 @@ namespace osu.Game.Utils BeatmapSets = realm.All().Count(), Beatmaps = realm.All().Count(), Files = realm.All().Count(), + Rulesets = realm.All().Count(), + RulesetsAvailable = realm.All().Count(r => r.Available), Skins = realm.All().Count(), } }; @@ -137,14 +141,25 @@ namespace osu.Game.Utils scope.Contexts[@"beatmap"] = new { Name = beatmap.ToString(), + Ruleset = beatmap.Ruleset.InstantiationInfo, beatmap.OnlineID, }; + scope.Contexts[@"ruleset"] = new + { + ruleset.ShortName, + ruleset.Name, + ruleset.InstantiationInfo, + ruleset.OnlineID + }; + scope.Contexts[@"clocks"] = new { Audio = game.Dependencies.Get().CurrentTrack.CurrentTime, Game = game.Clock.CurrentTime, }; + + scope.SetTag(@"ruleset", ruleset.ShortName); }); } else