diff --git a/.vscode/launch.json b/.vscode/launch.json index 6704225..a2e511b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,13 +1,15 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "args": [ - "-pn" - ], // <--- ADD OR MODIFY THIS LINE + "-test 12h45m 724733451895455700" + ] + }, + { + "name": "C#: Launch Startup Project", + "type": "dotnet", + "request": "launch" } ] } \ No newline at end of file diff --git a/URLNotesGrabberCORE/DataAccess.cs b/URLNotesGrabberCORE/DataAccess.cs index 8536ddb..083e02c 100644 --- a/URLNotesGrabberCORE/DataAccess.cs +++ b/URLNotesGrabberCORE/DataAccess.cs @@ -538,6 +538,9 @@ namespace URLNotesGrabberCORE try { + // Informative output when marking a post as NotFound + Console.WriteLine($"Marking post NotFound: {blogName}/{postID}"); + connection.Open(); string sql = "UPDATE Posts SET NotFound = 1 WHERE BlogName = @BlogName AND PostID = @PostID"; diff --git a/URLNotesGrabberCORE/Program.cs b/URLNotesGrabberCORE/Program.cs index 0b9e2e8..44d084c 100644 --- a/URLNotesGrabberCORE/Program.cs +++ b/URLNotesGrabberCORE/Program.cs @@ -71,6 +71,7 @@ namespace URLNotesGrabberCORE TraverseDirectory(settings.GetValue("PathInput"), settings.GetValue("PathOutputBlogs"), contains, blogNameToParse); break; + case "-test": #region Manual test @@ -80,6 +81,14 @@ namespace URLNotesGrabberCORE var response = APIAccess.GrabNotes(blogName, postID).GetAwaiter().GetResult(); List> notes = new List>(); + // If the API returned a 404 inside the JSON `meta` block, mark the post NotFound + if (response?.meta != null && response.meta.status == 404) + { + Console.WriteLine($"ERROR: Post not found - {blogName}/{postID} (meta.status=404)"); + DataAccess.UpdatePostMarkNotFound(blogName, postID); + break; + } + // Check for API errors if (response.statusCode == "NotFound") { @@ -332,6 +341,15 @@ namespace URLNotesGrabberCORE Console.WriteLine(post.Item1 + '\t' + post.Item2 + '\t' + DateTime.Now + "\t" + APICount); var response = APIAccess.GrabNotes(post.Item1, post.Item2, post.Item3.ToString()).GetAwaiter().GetResult(); + + // If the API returned a 404 inside the JSON `meta` block, mark the post NotFound and return + if (response?.meta != null && response.meta.status == 404) + { + Console.WriteLine($"API returned 404 Not Found for {post.Item1}/{post.Item2} (meta.status=404)"); + DataAccess.UpdatePostMarkNotFound(post.Item1, post.Item2); + Thread.Sleep(1000); + return "NotFound"; + } List> notes = new List>(); if (response.statusCode == "NotFound")