From e4a23b3e7d7eb065578f48c2d53e7981e37c6a59 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 12 May 2020 12:39:04 +0900 Subject: [PATCH] Fix ignored excluding more than top level --- osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs | 10 ++++++++++ osu.Game/IO/OsuStorage.cs | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs index ed83ff358c..ef2b20de64 100644 --- a/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs +++ b/osu.Game.Tests/NonVisual/CustomDataDirectoryTest.cs @@ -133,6 +133,9 @@ namespace osu.Game.Tests.NonVisual // ensure we "use" cache host.Storage.GetStorageForDirectory("cache"); + // for testing nested files are not ignored (only top level) + host.Storage.GetStorageForDirectory("test-nested").GetStorageForDirectory("cache"); + string defaultStorageLocation = Path.Combine(Environment.CurrentDirectory, "headless", nameof(TestMigration)); Assert.That(storage.GetFullPath("."), Is.EqualTo(defaultStorageLocation)); @@ -141,6 +144,13 @@ namespace osu.Game.Tests.NonVisual Assert.That(storage.GetFullPath("."), Is.EqualTo(customPath)); + // ensure cache was not moved + Assert.That(host.Storage.ExistsDirectory("cache")); + + // ensure nested cache was moved + Assert.That(!host.Storage.ExistsDirectory(Path.Combine("test-nested", "cache"))); + Assert.That(storage.ExistsDirectory(Path.Combine("test-nested", "cache"))); + foreach (var file in OsuStorage.IGNORE_FILES) { Assert.That(host.Storage.Exists(file), Is.True); diff --git a/osu.Game/IO/OsuStorage.cs b/osu.Game/IO/OsuStorage.cs index 7c0b90e208..6dc25e871c 100644 --- a/osu.Game/IO/OsuStorage.cs +++ b/osu.Game/IO/OsuStorage.cs @@ -71,7 +71,7 @@ namespace osu.Game.IO { foreach (System.IO.FileInfo fi in target.GetFiles()) { - if (IGNORE_FILES.Contains(fi.Name)) + if (topLevelExcludes && IGNORE_FILES.Contains(fi.Name)) continue; fi.Delete(); @@ -79,7 +79,7 @@ namespace osu.Game.IO foreach (DirectoryInfo dir in target.GetDirectories()) { - if (IGNORE_DIRECTORIES.Contains(dir.Name)) + if (topLevelExcludes && IGNORE_DIRECTORIES.Contains(dir.Name)) continue; dir.Delete(true); @@ -93,7 +93,7 @@ namespace osu.Game.IO foreach (System.IO.FileInfo fi in source.GetFiles()) { - if (IGNORE_FILES.Contains(fi.Name)) + if (topLevelExcludes && IGNORE_FILES.Contains(fi.Name)) continue; int tries = 5; @@ -114,7 +114,7 @@ namespace osu.Game.IO foreach (DirectoryInfo dir in source.GetDirectories()) { - if (IGNORE_DIRECTORIES.Contains(dir.Name)) + if (topLevelExcludes && IGNORE_DIRECTORIES.Contains(dir.Name)) continue; copyRecursive(dir, destination.CreateSubdirectory(dir.Name), false);