From 12350d18b522f073074b28e25f0daa45f1ac3d15 Mon Sep 17 00:00:00 2001 From: HoLLy Date: Thu, 27 Jun 2019 14:41:11 +0200 Subject: [PATCH] Don't remove imported archives by default --- osu.Game/Beatmaps/BeatmapManager.cs | 2 ++ osu.Game/Database/ArchiveModelManager.cs | 7 ++++++- osu.Game/Skinning/SkinManager.cs | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index da47ce7aab..cbaecdc8a7 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -83,6 +83,8 @@ namespace osu.Game.Beatmaps protected override IEnumerable GetStableImportPaths() => GetStableStorage().GetDirectories(ImportFromStablePath); + protected override bool ShouldRemoveArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osz"; + protected override Task Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive, CancellationToken cancellationToken = default) { if (archive != null) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index b1756c1790..939333c6f4 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -176,7 +176,7 @@ namespace osu.Game.Database // TODO: Add a check to prevent files from storage to be deleted. try { - if (import != null && File.Exists(path)) + if (import != null && File.Exists(path) && ShouldRemoveArchive(path)) File.Delete(path); } catch (Exception e) @@ -503,6 +503,11 @@ namespace osu.Game.Database /// protected abstract IEnumerable GetStableImportPaths(); + /// + /// Should this archive be removed after importing? + /// + protected virtual bool ShouldRemoveArchive(string path) => false; + /// /// This is a temporary method and will likely be replaced by a full-fledged (and more correctly placed) migration process in the future. /// diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 899bab8b94..cf1e9368bc 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -56,6 +56,8 @@ namespace osu.Game.Skinning protected override IEnumerable GetStableImportPaths() => GetStableStorage().GetDirectories(ImportFromStablePath); + protected override bool ShouldRemoveArchive(string path) => true; + /// /// Returns a list of all usable s. Includes the special default skin plus all skins from . ///