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; logManager.NewMessage += LogManager_NewMessage;
new Thread(() => new Thread(() =>
{ {
this.Invoke((MethodInvoker)delegate {
CheckPaths();
});
serverConnector.Reconnect(); serverConnector.Reconnect();
if (!serverConnector.Connected) if (!serverConnector.Connected)
{ {
@@ -48,7 +51,14 @@ namespace OpenSaveCloudClient
} }
else else
{ {
saveManager.DetectChanges(); try
{
saveManager.DetectChanges();
}
catch (Exception e)
{
logManager.AddError(e);
}
this.Invoke((MethodInvoker)delegate { this.Invoke((MethodInvoker)delegate {
SetAdminControls(); SetAdminControls();
AboutButton.Enabled = true; AboutButton.Enabled = true;
@@ -62,6 +72,36 @@ namespace OpenSaveCloudClient
}); });
} }
}).Start(); }).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(); RefreshList();
} }
@@ -82,7 +122,14 @@ namespace OpenSaveCloudClient
{ {
new Thread(() => new Thread(() =>
{ {
saveManager.DetectChanges(); try
{
saveManager.DetectChanges();
}
catch (Exception e)
{
logManager.AddError(e);
}
}).Start(); }).Start();
SetAdminControls(); SetAdminControls();
Enabled = true; Enabled = true;

View File

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