Skip to content

Commit

Permalink
fix crash on bad nasa format
Browse files Browse the repository at this point in the history
  • Loading branch information
wiegell committed Nov 26, 2022
1 parent 5f1a4db commit 15f7ca8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AstroWall/BusinessLayer/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public async Task LoadImgs(bool forceReload = false)
ImgLoadList = new List<Task>();
foreach (ImgWrap pw in ImgWrapList)
{
if (pw.OnlineDataExceptPicIsLoaded() && pw.Integrity && pw.ImgIsGettable)
if (pw.Integrity && pw.ImgIsGettable)
ImgLoadList.Add(Task.Run(() => pw.LoadImg()));
}
await Task.WhenAll(ImgLoadList);
Expand Down
7 changes: 5 additions & 2 deletions AstroWall/BusinessLayer/ImgWrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public async Task LoadImg()

try
{
Console.WriteLine("Commencing download of date: " + this.PublishDate);
ImgLocalUrl = await FileHelpers.DownloadUrlToImageStorePath(ImgOnlineUrl);
await createPreviewFromFullSize();
}
Expand Down Expand Up @@ -191,6 +192,8 @@ public async Task createPostProcessedImages(Dictionary<string, Screen> screens,
SKBitmap image;
try
{
Console.WriteLine("Trying to load image at local url: " + ImgLocalUrl);
Console.WriteLine(FileHelpers.SerializeNow(this));
image = await FileHelpers.LoadImageFromLocalUrl(ImgLocalUrl);
}
catch (Exception ex)
Expand Down Expand Up @@ -230,8 +233,8 @@ public async Task createPostProcessedImages(Dictionary<string, Screen> screens,
}
catch (Exception ex)
{
Console.WriteLine("Error postprocessing image ({0}): {1}", ImgLocalUrl, ex.Message);
throw new Exception($"Error postprocessing image ({ImgLocalUrl}): {ex.Message}", ex);
Console.WriteLine("Error postprocessing image ({0}): {1}", ImgLocalUrl, ex.Message, ex.StackTrace);
throw new Exception("error postprocessing", ex);
}

//Remove old postprocessed files
Expand Down
2 changes: 1 addition & 1 deletion AstroWall/BusinessLayer/Wallpaper/PostProcess/AddText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public PostProcess()
throw ex;
}

if (options.isEnabled)
if (options.isEnabled && description != null && description != "" && title != null && title != "" && credit != null && credit != "")
{
// Format description
string descriptionFormatted = description.Replace("\n", " ").Replace("Explanation:", "").Replace(" ", " ").Replace(" ", " ").Replace(" ", " ").TrimStart();
Expand Down
2 changes: 1 addition & 1 deletion AstroWall/BusinessLayer/Wallpaper/Wallpaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task<bool> RunPostProcessAndSetWallpaperAllScreens(ImgWrap imgWrap)
General.RunOnUIThread(() =>
{
Console.WriteLine("Exception in postProcess task on thread: " + Thread.CurrentThread.ManagedThreadId);
throw newEx;
throw ex;
});

// This will not bubble up
Expand Down
4 changes: 4 additions & 0 deletions AstroWall/DataLayer/FileHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public async static Task<SKBitmap> LoadImageFromLocalUrl(string path)
return bitmap;
}

public static string SerializeNow(Object c)
{
return JsonConvert.SerializeObject(c);
}
public static void SerializeNow(Object c, string path)
{
string jsonString = JsonConvert.SerializeObject(c);
Expand Down

0 comments on commit 15f7ca8

Please sign in to comment.