Add protection against migrating to a nested folder

This commit is contained in:
Dean Herbert
2020-05-14 22:42:42 +09:00
parent 9d557bf806
commit ef8375b442
2 changed files with 30 additions and 0 deletions

View File

@ -48,6 +48,12 @@ 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));
if (destination.FullName.Contains(source.FullName))
throw new ArgumentException("Destination provided is inside the source", nameof(newLocation));
// ensure the new location has no files present, else hard abort
if (destination.Exists)
{