Handle directory checking before entering task

This commit is contained in:
Paul Teng 2018-09-17 21:05:28 -04:00
parent 000beea01b
commit 8bfd981a50

View File

@ -438,19 +438,14 @@ namespace osu.Game.Database
return Task.CompletedTask; return Task.CompletedTask;
} }
return Task.Factory.StartNew(() => if (!stable.ExistsDirectory(ImportFromStablePath))
{ {
try // This handles situations like when the user does not have a Skins folder
{ Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error);
Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()); return Task.CompletedTask;
} }
catch (DirectoryNotFoundException)
{ return Task.Factory.StartNew(() => Import(stable.GetDirectories(ImportFromStablePath).Select(f => stable.GetFullPath(f)).ToArray()), TaskCreationOptions.LongRunning);
// This handles situations like when the user does not have a Skins folder
// which would have this exception thrown from stable.GetDirectories
Logger.Log("No " + ImportFromStablePath + " folder available in osu!stable installation", LoggingTarget.Information, LogLevel.Error);
}
}, TaskCreationOptions.LongRunning);
} }
#endregion #endregion