Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2264: Fix UI freezing if navigate to parent fails and avoid duplicating replied messages in the case #2269

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions iped-app/src/main/java/iped/app/ui/TreeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import iped.app.ui.TreeViewModel.Node;
import iped.app.ui.filters.QueryFilter;
import iped.engine.data.IPEDSource;
import iped.engine.search.LuceneSearchResult;
import iped.engine.search.QueryBuilder;
import iped.engine.task.index.IndexItem;
import iped.exception.ParseException;
Expand All @@ -53,6 +54,8 @@

public class TreeListener extends MouseAdapter implements TreeSelectionListener, ActionListener, TreeExpansionListener, IQueryFilterer {

private static final Logger logger = LoggerFactory.getLogger(TreeListener.class);

private Query treeQuery, recursiveTreeQuery;
boolean rootSelected = false;
HashSet<TreePath> selection = new HashSet<TreePath>();
Expand Down Expand Up @@ -121,24 +124,27 @@ public void valueChanged(TreeSelectionEvent evt) {
public void navigateToParent(int docId) {

LinkedList<Node> path = new LinkedList<Node>();
LuceneSearchResult result = new LuceneSearchResult(0);
String parentId = null;
do {
try {
try {
do {
Document doc = App.get().appCase.getReader().document(docId);

parentId = doc.get(IndexItem.PARENTID);
if (parentId != null) {
IPEDSource src = (IPEDSource) App.get().appCase.getAtomicSource(docId);
docId = App.get().appCase.getBaseLuceneId(src) + src.getLuceneId(Integer.parseInt(parentId));
docId = src.getLuceneId(Integer.parseInt(parentId));
if (docId == -1) {
throw new RuntimeException("Parent with id = " + parentId + " not found in the index");
}
docId += App.get().appCase.getBaseLuceneId(src);
path.addFirst(((TreeViewModel) App.get().tree.getModel()).new Node(docId));
}
} while (parentId != null);

} catch (Exception e) {
e.printStackTrace();
}

} while (parentId != null);
} catch (Exception e) {
logger.error("Navigate to parent failed!", e);
return;
}

path.addFirst((Node) App.get().tree.getModel().getRoot());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ else if (parentItem.getMediaType().equals(MediaTypes.UFED_MESSAGE_MIME)) {
item.getMetadata().set(ExtraProperties.MESSAGE_BODY, body);
}
int numInstantMsgAttachs = 0;
boolean ignoreItemLocal = false;
if ("InstantMessage".equals(type)) {
numInstantMsgAttachs = this.numAttachments;
if (numInstantMsgAttachs > 0) {
Expand All @@ -904,6 +905,13 @@ else if (parentItem.getMediaType().equals(MediaTypes.UFED_MESSAGE_MIME)) {
UFEDChatParser.ATTACHED_MEDIA_MSG + numInstantMsgAttachs);
}
this.numAttachments = 0;
if (!itemSeq.isEmpty()) {
IItem parentItem = itemSeq.get(itemSeq.size() - 1);
// See https://github.com/sepinf-inc/IPED/issues/2264#issuecomment-2254192462
if (parentItem.getName().startsWith("ReplyMessageData_")) {
ignoreItemLocal = true;
}
}
}
if (mergeInParentNode.contains(type) && itemSeq.size() > 0) {
IItem parentItem = itemSeq.get(itemSeq.size() - 1);
Expand Down Expand Up @@ -1067,7 +1075,11 @@ else if ("Bcc".equalsIgnoreCase(role)) //$NON-NLS-1$
String ufedId = item.getMetadata().get(ExtraProperties.UFED_META_PREFIX + "id");
// add items if not ignoring already added instant message xml tree
if (ignoreItemTree == null) {
processItem(item);
if (!ignoreItemLocal) {
processItem(item);
} else {
caseData.incDiscoveredEvidences(-1);
}
if ("InstantMessage".equals(type)) {
// remember IM ids to not add them again later
addedImUfedIds.add(ufedId);
Expand Down
Loading