diff --git a/AssM.csproj b/AssM.csproj
index 559ab34..a260186 100644
--- a/AssM.csproj
+++ b/AssM.csproj
@@ -5,11 +5,11 @@
enable
true
app.manifest
- 1.7.0
+ 1.7.1
SubZeroPL
https://github.com/SubZeroPL/AssM
- 1.7.0
- 1.7.0
+ 1.7.1
+ 1.7.1
AssM
https://github.com/SubZeroPL/AssM/blob/master/LICENSE
https://github.com/SubZeroPL/AssM/
diff --git a/Classes/Functions.cs b/Classes/Functions.cs
index 64ca5fc..ed3298c 100644
--- a/Classes/Functions.cs
+++ b/Classes/Functions.cs
@@ -78,14 +78,18 @@ public static void LoadExistingData(Game game, Configuration configuration, stri
readmePath ??= Path.Combine(configuration.OutputDirectory, OutputPath(game), Constants.ReadmeFile);
if (!File.Exists(readmePath)) game.ReadmeCreated = false;
- if (string.IsNullOrWhiteSpace(game.Description) && !game.Modified)
+ if (!game.Modified)
{
- LoadDescriptionFromReadme(readmePath, game);
+ if (!LoadTitleFromReadme(readmePath, game))
+ {
+ Logger.Error($"Failed to load title from {readmePath}");
+ throw new ProcessingException($"Failed to load title from {readmePath}. Readme file is malformed");
+ }
}
-
- if (!game.Modified)
+
+ if (string.IsNullOrWhiteSpace(game.Description) && !game.Modified)
{
- LoadTitleFromReadme(readmePath, game);
+ LoadDescriptionFromReadme(readmePath, game);
}
LoadTrackInfoFromReadme(readmePath, game);
@@ -113,17 +117,23 @@ public static void LoadExistingData(Game game, Configuration configuration, stri
Logger.Debug($"Loaded existing data from {readmePath} for game {game.Title}");
}
- private static void LoadTitleFromReadme(string readmePath, Game game)
+ private static bool LoadTitleFromReadme(string readmePath, Game game)
{
Logger.Debug($"Loading title from {readmePath}");
- if (!File.Exists(readmePath)) return;
- if (game.Modified) return;
+ if (!File.Exists(readmePath)) return false;
+ if (game.Modified) return false;
var lines = File.ReadAllLines(readmePath);
var index = Array.FindIndex(lines, line => line.Contains("**Game name:**"));
var endIndex = Array.FindIndex(lines, line => line.Contains("**Game ID:**"));
+ if (index < 0 || endIndex < 0)
+ {
+ Logger.Error($"Failed to load title from {readmePath}. Readme file is malformed");
+ return false;
+ }
var title = string.Join("", lines.Skip(index + 1).Take(new Range(1, endIndex - 1))).Trim();
if (!string.IsNullOrEmpty(title)) game.Title = title;
game.ReadmeCreated = true;
+ return true;
}
private static void LoadDescriptionFromReadme(string readmePath, Game game)
diff --git a/Windows/MainWindow.axaml.cs b/Windows/MainWindow.axaml.cs
index d968ff2..f18b876 100644
--- a/Windows/MainWindow.axaml.cs
+++ b/Windows/MainWindow.axaml.cs
@@ -105,9 +105,12 @@ private void AddButton_OnClick(object? sender, RoutedEventArgs e)
{
AllowMultiple = true,
Title = "Select images",
- FileTypeFilter = [ new FilePickerFileType("All supported formats (*.cue, *.iso)") { Patterns = ["*.cue", "*.iso"] },
+ FileTypeFilter =
+ [
+ new FilePickerFileType("All supported formats (*.cue, *.iso)") { Patterns = ["*.cue", "*.iso"] },
new FilePickerFileType("CUE file (*.cue)") { Patterns = ["*.cue"] },
- new FilePickerFileType("ISO file (*.iso)") { Patterns = ["*.iso"] }]
+ new FilePickerFileType("ISO file (*.iso)") { Patterns = ["*.iso"] }
+ ]
};
var files = GetTopLevel(this)?.StorageProvider.OpenFilePickerAsync(fpo).GetAwaiter().GetResult() ??
new List();
@@ -266,9 +269,16 @@ private void AddReadmes(string directory)
var readmeList = Functions.GetReadmeFilesInDirectory(directory);
foreach (var readme in readmeList)
{
- var game = new Game();
- Functions.LoadExistingData(game, Configuration, readme);
- if (!GameList.Any(g => g.Id.Equals(game.Id))) GameList.Add(game);
+ try
+ {
+ var game = new Game();
+ Functions.LoadExistingData(game, Configuration, readme);
+ if (!GameList.Any(g => g.Id.Equals(game.Id))) GameList.Add(game);
+ }
+ catch (Exception ex)
+ {
+ _logger.Error(ex, $"Failed to load readme {readme}");
+ }
}
DataGridGameList.CollectionView.Refresh();