+15
-6
osu.Framework.Tests/Platform/UserStorageLookupTest.cs
+15
-6
osu.Framework.Tests/Platform/UserStorageLookupTest.cs
···
22
22
{
23
23
try
24
24
{
25
+
File.Delete(path1);
26
+
File.Delete(path2);
27
+
}
28
+
catch
29
+
{
30
+
}
31
+
32
+
try
33
+
{
25
34
Directory.Delete(path1, true);
26
35
Directory.Delete(path2, true);
27
36
}
···
43
52
}
44
53
45
54
[Test]
46
-
public void TestSecondBaseExisting()
55
+
public void TestSecondBaseExistingStillPrefersFirst()
47
56
{
48
57
Directory.CreateDirectory(path2);
49
58
50
59
using (var host = new StorageLookupHeadlessGameHost())
51
60
{
52
61
runHost(host);
53
-
Assert.IsTrue(host.Storage.GetFullPath(string.Empty).StartsWith(path2, StringComparison.Ordinal));
62
+
Assert.IsTrue(host.Storage.GetFullPath(string.Empty).StartsWith(path1, StringComparison.Ordinal));
54
63
}
55
64
}
56
65
57
66
[Test]
58
-
public void TestPrefersFirstBase()
67
+
public void TestSecondBaseUsedIfFirstFails()
59
68
{
60
-
Directory.CreateDirectory(path1);
61
-
Directory.CreateDirectory(path2);
69
+
// write a file so directory creation fails.
70
+
File.WriteAllText(path1, "");
62
71
63
72
using (var host = new StorageLookupHeadlessGameHost())
64
73
{
65
74
runHost(host);
66
-
Assert.IsTrue(host.Storage.GetFullPath(string.Empty).StartsWith(path1, StringComparison.Ordinal));
75
+
Assert.IsTrue(host.Storage.GetFullPath(string.Empty).StartsWith(path2, StringComparison.Ordinal));
67
76
}
68
77
}
69
78
+9
-5
osu.Framework/Platform/GameHost.cs
+9
-5
osu.Framework/Platform/GameHost.cs
···
695
695
return storage.GetStorageForDirectory(Name);
696
696
}
697
697
698
-
// if an existing directory could not be found, use the first available valid path.
698
+
// if an existing directory could not be found, use the first path that can be created.
699
699
foreach (var path in UserStoragePaths)
700
700
{
701
-
var storage = GetStorage(path);
702
-
703
-
if (storage.ExistsDirectory(string.Empty))
704
-
return storage.GetStorageForDirectory(Name);
701
+
try
702
+
{
703
+
return GetStorage(path).GetStorageForDirectory(Name);
704
+
}
705
+
catch
706
+
{
707
+
// may fail on directory creation.
708
+
}
705
709
}
706
710
707
711
throw new InvalidOperationException("No valid user storage path could be resolved.");