From f6dcf550bf90f57f320dcf7e24b309e86d0477f7 Mon Sep 17 00:00:00 2001
From: Kelly Kelly <kelly@basistech.com>
Date: Thu, 11 Nov 2021 11:37:27 -0500
Subject: [PATCH] Fixed the refresh for content

---
 .../mainui/datamodel/FileSystemDAO.java       | 35 ++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java
index fc7ac32885..19df7cfcd2 100644
--- a/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java
+++ b/Core/src/org/sleuthkit/autopsy/mainui/datamodel/FileSystemDAO.java
@@ -31,6 +31,7 @@
 import java.util.stream.Stream;
 import org.sleuthkit.autopsy.casemodule.Case;
 import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
+import org.sleuthkit.autopsy.ingest.ModuleDataEvent;
 import org.sleuthkit.autopsy.mainui.datamodel.FileSystemRowDTO.DirectoryRowDTO;
 import org.sleuthkit.autopsy.mainui.datamodel.FileSystemRowDTO.ImageRowDTO;
 import org.sleuthkit.autopsy.mainui.datamodel.FileSystemRowDTO.VolumeRowDTO;
@@ -79,6 +80,27 @@ synchronized static FileSystemDAO getInstance() {
         }
         return instance;
     }
+    
+    public boolean isSystemContentInvalidating(FileSystemContentSearchParam key, Content eventContent) {
+        if(!(eventContent instanceof Content)) {
+            return false;
+        }
+        
+        try {
+            return key.getContentObjectId() != eventContent.getParent().getId();
+        } catch (TskCoreException ex) {
+            // There is nothing we can do with the exception.
+            return false;
+        }
+    }
+    
+    public boolean isSystemHostInvalidating(FileSystemHostSearchParam key, Host eventHost) {
+        if(!(eventHost instanceof Host)) {
+            return false;
+        }
+        
+        return key.getHostObjectId() != eventHost.getHostId();
+    }
 
     private BaseSearchResultsDTO fetchContentForTableFromContent(SearchParams<FileSystemContentSearchParam> cacheKey) throws NoCurrentCaseException, TskCoreException {
 
@@ -290,13 +312,12 @@ public SearchResultsDTO getSearchResults(int pageSize, int pageIdx, boolean hard
 
         @Override
         public boolean isRefreshRequired(PropertyChangeEvent evt) {
-            Content content = this.getContentFromEvt(evt);
+            Content content = getContentFromEvt(evt);
             if (content == null) {
                 return false;
             }
 
-            // I am not sure what to do here.
-            return false;
+            return MainDAO.getInstance().getFileSystemDAO().isSystemContentInvalidating(getParameters(), content);
         }
     }
 
@@ -318,12 +339,8 @@ public SearchResultsDTO getSearchResults(int pageSize, int pageIdx, boolean hard
 
         @Override
         public boolean isRefreshRequired(PropertyChangeEvent evt) {
-            Content content = this.getContentFromEvt(evt);
-            if (content == null) {
-                return false;
-            }
-
-            // I am not sure what to do here.
+            // TODO implement the method for determining if 
+            // a refresh is needed.
             return false;
         }
     }
-- 
GitLab