From 85ea1bbee6c7b3069f9c0432f213f7392eb9da26 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Sat, 7 Apr 2012 17:23:36 +0000 Subject: [PATCH] Fixed some bugs with import of discussion threads? --- FLocal.Migration.Console/ShallerDBProcessor.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/FLocal.Migration.Console/ShallerDBProcessor.cs b/FLocal.Migration.Console/ShallerDBProcessor.cs index 44b186e..a86ea8f 100644 --- a/FLocal.Migration.Console/ShallerDBProcessor.cs +++ b/FLocal.Migration.Console/ShallerDBProcessor.cs @@ -253,12 +253,14 @@ namespace FLocal.Migration.Console { layer = PostLayer.LoadById(int.Parse(data["Layer"])); } inserts[postId] = () => { + bool isDiscussion = false; if(postId == main || postId == localMain) { //first post in the thread string legacyBoardName; - if(localMain != 0) { + if(discussions.ContainsKey(main) || (localMain != 0 && (localMain != postId || localMain != main))) { discussionsIds.Add(main); legacyBoardName = discussions[main]; + isDiscussion = true; } else { legacyBoardName = data["Board"]; } @@ -277,13 +279,18 @@ namespace FLocal.Migration.Console { parentId = main; } } - Post post; + Post parent; try { - post = Post.LoadById(parentId); + parent = Post.LoadById(parentId); } catch(NotFoundInDBException) { throw new ApplicationException("Cannot find parent post #" + parentId); } - post.Reply(user, title, body, layer, date, postId); + + if(!isDiscussion && parent.thread.firstPostId != localMain) { + System.Console.Write("d"); + } else { + parent.Reply(user, title, body, layer, date, postId); + } } }; System.Console.Write("+");