speed up no-args directory import with shared connection + lazy blog cache

AddBlog/AddPost/UpdatePost/UpdatePostSetDate now reuse a single SQLiteConnection
when an import session is active, instead of opening and closing one per call.
AddBlog also short-circuits on an in-memory HashSet of blog names already
attempted this run. Other entry points are unaffected since they never call
BeginImportSession.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
jim
2026-05-15 11:51:57 -05:00
co-authored by Claude Opus 4.7
parent 52293f2021
commit 2634ff8967
2 changed files with 84 additions and 15 deletions
+2
View File
@@ -124,10 +124,12 @@ namespace URLNotesGrabberCORE
try
{
DataAccess.EnableImportModePragmas();
DataAccess.BeginImportSession();
TraverseDirectory(settings.GetValue<string>("PathInput"), settings.GetValue<string>("PathOutputBlogs"), contains, ref postsAdded, startFromBlogName: startFromBlogName, logRecordImports: logTraversalRecordImports);
}
finally
{
DataAccess.EndImportSession();
DataAccess.RestoreImportModePragmas();
}
Console.WriteLine($"Total posts added: {postsAdded}");