invert if-statement and early return + reuse of checkExists

This commit is contained in:
Shivam 2020-05-20 17:25:53 +02:00
parent 15ebe38303
commit b1c957c5e1
2 changed files with 29 additions and 29 deletions

View File

@ -157,7 +157,7 @@ namespace osu.Game.Tournament.IPC
return IPCStorage;
}
private static bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
public bool checkExists(string p) => File.Exists(Path.Combine(p, "ipc.txt"));
private string findStablePath()
{

View File

@ -140,10 +140,19 @@ namespace osu.Game.Tournament.Screens
private void changePath(Storage storage)
{
var target = directorySelector.CurrentDirectory.Value.FullName;
var fileBasedIpc = ipc as FileBasedIPC;
Logger.Log($"Changing Stable CE location to {target}");
if (File.Exists(Path.Combine(target, "ipc.txt")))
if (!fileBasedIpc.checkExists(target))
{
overlay = new DialogOverlay();
overlay.Push(new IPCErrorDialog("This is an invalid IPC Directory", "Select a directory that contains an osu! stable cutting edge installation and make sure it has an empty ipc.txt file in it."));
AddInternal(overlay);
Logger.Log("Folder is not an osu! stable CE directory");
return;
// Return an error in the picker that the directory does not contain ipc.txt
}
stableInfo.StablePath.Value = target;
try
@ -160,7 +169,7 @@ namespace osu.Game.Tournament.Screens
}));
}
var fileBasedIpc = ipc as FileBasedIPC;
fileBasedIpc?.LocateStableStorage();
sceneManager?.SetScreen(typeof(SetupScreen));
}
@ -169,15 +178,6 @@ namespace osu.Game.Tournament.Screens
Logger.Log($"Error during migration: {e.Message}", level: LogLevel.Error);
}
}
else
{
overlay = new DialogOverlay();
overlay.Push(new IPCErrorDialog("This is an invalid IPC Directory", "Select a directory that contains an osu! stable cutting edge installation and make sure it has an empty ipc.txt file in it."));
AddInternal(overlay);
Logger.Log("Folder is not an osu! stable CE directory");
// Return an error in the picker that the directory does not contain ipc.txt
}
}
private void autoDetect()
{