1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 20:23:00 +08:00

Throw better exceptions from OsuStorage

This commit is contained in:
Dean Herbert 2020-05-13 22:57:41 +09:00
parent 6bb06e9d61
commit cb0b25ac55

View File

@ -48,11 +48,14 @@ namespace osu.Game.IO
var source = new DirectoryInfo(GetFullPath("."));
var destination = new DirectoryInfo(newLocation);
if (source.FullName == destination.FullName)
throw new ArgumentException("Destination provided is already the current location", nameof(newLocation));
// ensure the new location has no files present, else hard abort
if (destination.Exists)
{
if (destination.GetFiles().Length > 0 || destination.GetDirectories().Length > 0)
throw new InvalidOperationException("Migration destination already has files present");
throw new ArgumentException("Destination provided already has files or directories present", nameof(newLocation));
deleteRecursive(destination);
}