removed redundant code and use existing checkExists

This commit is contained in:
Shivam
2020-05-20 22:16:37 +02:00
parent a5c2f97a76
commit d2416ce30d
2 changed files with 21 additions and 48 deletions

View File

@ -139,39 +139,26 @@ 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 (!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
{
using (var stream = storage.GetStream(StableInfo.STABLE_CONFIG, FileAccess.Write, FileMode.Create))
using (var sw = new StreamWriter(stream))
var target = directorySelector.CurrentDirectory.Value.FullName;
stableInfo.StablePath.Value = target;
var fileBasedIpc = ipc as FileBasedIPC;
Logger.Log($"Changing Stable CE location to {target}");
if (!fileBasedIpc.checkExists(target))
{
sw.Write(JsonConvert.SerializeObject(stableInfo,
new JsonSerializerSettings
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore,
}));
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
}
fileBasedIpc?.LocateStableStorage();
sceneManager?.SetScreen(typeof(SetupScreen));
fileBasedIpc.LocateStableStorage();
sceneManager.SetScreen(typeof(SetupScreen));
}
catch (Exception e)
{
@ -181,7 +168,6 @@ namespace osu.Game.Tournament.Screens
private void autoDetect()
{
stableInfo.StablePath.Value = string.Empty; // This forces findStablePath() to look elsewhere.
var fileBasedIpc = ipc as FileBasedIPC;
fileBasedIpc?.LocateStableStorage();