mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 01:07:42 +00:00
handle cache clears from preference updates
This commit is contained in:
parent
7e9001305d
commit
8cedfcda60
@ -105,6 +105,7 @@ import org.sleuthkit.autopsy.mainui.datamodel.ViewsDAO.DeletedFileFetcher;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.DeletedContentSearchParams;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.ReportsDAO.ReportsFetcher;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.ReportsSearchParams;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.events.CacheClearEvent;
|
||||
import org.sleuthkit.autopsy.mainui.nodes.ChildNodeSelectionInfo;
|
||||
import org.sleuthkit.autopsy.mainui.nodes.SearchManager;
|
||||
|
||||
@ -189,10 +190,19 @@ public class DataResultPanel extends javax.swing.JPanel implements DataResult, C
|
||||
|
||||
private final PropertyChangeListener DAOListener = evt -> {
|
||||
SearchManager manager = this.searchResultManager;
|
||||
if (manager != null && evt != null && evt.getNewValue() instanceof DAOAggregateEvent) {
|
||||
DAOAggregateEvent daoAggrEvt = (DAOAggregateEvent) evt.getNewValue();
|
||||
if (daoAggrEvt.getEvents().stream().anyMatch((daoEvt) -> manager.isRefreshRequired(daoEvt))) {
|
||||
refreshSearchResultChildren();
|
||||
if (manager != null && evt != null) {
|
||||
if (evt.getNewValue() instanceof DAOAggregateEvent) {
|
||||
DAOAggregateEvent daoAggrEvt = (DAOAggregateEvent) evt.getNewValue();
|
||||
if (daoAggrEvt.getEvents().stream().anyMatch((daoEvt) -> manager.isRefreshRequired(daoEvt))) {
|
||||
refreshSearchResultChildren();
|
||||
}
|
||||
} else if (evt.getNewValue() instanceof CacheClearEvent) {
|
||||
try {
|
||||
this.searchResultManager = new SearchManager(this.searchResultManager.getDaoFetcher(), getPageSize());
|
||||
displaySearchResults(this.searchResultManager.getResults(), true);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.log(Level.WARNING, "An exception occurred while handling cache clear event.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -43,6 +43,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.core.UserPreferences;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.events.CacheClearEvent;
|
||||
import org.sleuthkit.autopsy.mainui.datamodel.events.TreeEvent;
|
||||
|
||||
/**
|
||||
@ -276,6 +277,9 @@ public class MainDAO extends AbstractDAO {
|
||||
@Override
|
||||
void clearCaches() {
|
||||
allDAOs.forEach((subDAO) -> subDAO.clearCaches());
|
||||
resultEventsManager.firePropertyChange("DATA_CLEAR", null, CacheClearEvent.getInstance());
|
||||
treeEventsManager.firePropertyChange("TREE_CLEAR", null, CacheClearEvent.getInstance());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2022 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.mainui.datamodel.events;
|
||||
|
||||
/**
|
||||
* Event fired when all dao caches cleared.
|
||||
*/
|
||||
public class CacheClearEvent {
|
||||
|
||||
private final static CacheClearEvent instance = new CacheClearEvent();
|
||||
|
||||
/**
|
||||
* @return Singleton instance of this class.
|
||||
*/
|
||||
public static CacheClearEvent getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final String eventType = "CACHE_CLEAR";
|
||||
|
||||
|
||||
private CacheClearEvent() {}
|
||||
|
||||
/**
|
||||
* @return The event type string.
|
||||
*/
|
||||
public String getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user