Resolve path dialog

This commit is contained in:
Aurélie Delhaie
2022-06-07 22:48:45 +02:00
parent eb4ded0c5b
commit acee2b1c6a
10 changed files with 56 additions and 4 deletions

View File

@@ -39,6 +39,9 @@ namespace OpenSaveCloudClient
logManager.NewMessage += LogManager_NewMessage;
new Thread(() =>
{
this.Invoke((MethodInvoker)delegate {
CheckPaths();
});
serverConnector.Reconnect();
if (!serverConnector.Connected)
{
@@ -47,8 +50,15 @@ namespace OpenSaveCloudClient
});
}
else
{
try
{
saveManager.DetectChanges();
}
catch (Exception e)
{
logManager.AddError(e);
}
this.Invoke((MethodInvoker)delegate {
SetAdminControls();
AboutButton.Enabled = true;
@@ -62,6 +72,36 @@ namespace OpenSaveCloudClient
});
}
}).Start();
}
private void CheckPaths()
{
List<GameSave> toDelete = new();
foreach (GameSave save in saveManager.Saves)
{
if (!save.PathExist())
{
string message = String.Format("The path of '{0}' is not found\n\n{1}\n\nDo you want to locate the new path?", save.Name, save.FolderPath);
DialogResult res = MessageBox.Show(message, "Missing path", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
if (res == DialogResult.Yes)
{
FolderBrowserDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
save.FolderPath = dialog.SelectedPath;
}
}
else
{
toDelete.Add(save);
}
}
}
foreach (GameSave save in toDelete)
{
saveManager.Saves.Remove(save);
}
saveManager.Save();
RefreshList();
}
@@ -81,8 +121,15 @@ namespace OpenSaveCloudClient
} else
{
new Thread(() =>
{
try
{
saveManager.DetectChanges();
}
catch (Exception e)
{
logManager.AddError(e);
}
}).Start();
SetAdminControls();
Enabled = true;

View File

@@ -16,7 +16,7 @@ namespace OpenSaveCloudClient.Models
private long id;
private string uuid;
private readonly string name;
private readonly string folderPath;
private string folderPath;
private readonly string description;
private string hash;
private string currentHash;
@@ -28,7 +28,7 @@ namespace OpenSaveCloudClient.Models
public string Uuid { get { return uuid; } }
public string Name { get { return name; } }
public string Description { get { return description; } }
public string FolderPath { get { return folderPath; } }
public string FolderPath { get { return folderPath; } set { folderPath = value; } }
public string Hash { get { return hash; } }
public string CurrentHash { get { return currentHash; } }
public string? CoverPath { get { return coverPath; } }
@@ -110,5 +110,10 @@ namespace OpenSaveCloudClient.Models
{
hash = currentHash;
}
public bool PathExist()
{
return Directory.Exists(FolderPath);
}
}
}