diff --git a/c#/crawler/src/Tieba/Crawl/Saver/Post/PostSaver.cs b/c#/crawler/src/Tieba/Crawl/Saver/Post/PostSaver.cs index 9c8aebed..d0405362 100644 --- a/c#/crawler/src/Tieba/Crawl/Saver/Post/PostSaver.cs +++ b/c#/crawler/src/Tieba/Crawl/Saver/Post/PostSaver.cs @@ -26,7 +26,7 @@ protected SaverChangeSet Save( Func postIdSelector, Func revisionFactory, Func, IQueryable> postQueryTransformer, - Action>>? onBeforeSaveRevision = null) + Action>>? onBeforeSaveRevision = null) where TRevision : TBaseRevision { var existingPosts = postQueryTransformer(db.Set().AsTracking()).ToList(); @@ -41,7 +41,7 @@ from existingPost in existingPostsWithSameId.DefaultIfEmpty() var existingAndNewPosts = SaveNewEntities(db, maybeExistingAndNewPosts).ToList(); SaveExistingEntities(db, existingAndNewPosts); - onBeforeSaveRevision?.Invoke(existingAndNewPosts); + onBeforeSaveRevision?.Invoke(maybeExistingAndNewPosts); SaveExistingEntityRevisions(db, revisionFactory, existingAndNewPosts); return new(postIdSelector, existingPostsBeforeMerge, Posts.Values, existingPosts); } diff --git a/c#/crawler/src/Tieba/Crawl/Saver/Post/ThreadSaver.cs b/c#/crawler/src/Tieba/Crawl/Saver/Post/ThreadSaver.cs index a5cab2a7..426f3d4a 100644 --- a/c#/crawler/src/Tieba/Crawl/Saver/Post/ThreadSaver.cs +++ b/c#/crawler/src/Tieba/Crawl/Saver/Post/ThreadSaver.cs @@ -16,9 +16,9 @@ public override SaverChangeSet Save(CrawlerDbContext db) => Save(db, posts => posts .Where(th => Posts.Keys.Contains(th.Tid)) .Include(th => th.LatestReplier), - existingAndNewPosts => + maybeEntities => PostSaveHandlers += threadLatestReplierSaver.SaveFromThread(db, - existingAndNewPosts.Select(t => t.Existing).ToList())); + maybeEntities.Select(entity => entity.Existing ?? entity.New).ToList())); } public partial class ThreadSaver {