Skip to content

Commit

Permalink
handle un-reloadable threads
Browse files Browse the repository at this point in the history
  • Loading branch information
murrty committed Jan 14, 2024
1 parent 7e8f8cd commit f0f68e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/YChanEx/Classes/ProgramSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ public static List<ThreadData> LoadThreads() {

if (SavedFiles.Count > 0) {
for (int i = 0; i < SavedFiles.Count; i++) {
ThreadData Thread = File.ReadAllText(SavedFiles[i].FullName).JsonDeserialize<ThreadData>();
if (Thread == null) {
continue;
try {
ThreadData Thread = File.ReadAllText(SavedFiles[i].FullName).JsonDeserialize<ThreadData>();
if (Thread == null) {
continue;
}
Thread.FilePath = SavedFiles[i].FullName;
list.Add(Thread);
}
catch {
File.Move(SavedFiles[i].FullName, SavedFiles[i].FullName + ".broken");
}
Thread.FilePath = SavedFiles[i].FullName;
list.Add(Thread);
}
//list.Sort((x, y) => x.QueueIndex.CompareTo(y.QueueIndex));
}
Expand Down
8 changes: 6 additions & 2 deletions src/YChanEx/Forms/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ private void CheckThreads() {
var Thread = SavedThreads[i];
this.Invoke(() => LoadSavedThread(Thread, Thread.FilePath));
}
catch (Exception ex) {
murrty.classes.Log.ReportException(ex);
catch {
this.Invoke(() => {
MessageBox.Show("Could not load saved thread. It will need to be redownloaded.");
SavedThreads.RemoveAt(i);
lvThreads.Items.RemoveAt(i--);
});
}
Thread.Sleep(500);
}
Expand Down

0 comments on commit f0f68e5

Please sign in to comment.