diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/utils/DataSourceLoader.java b/Core/src/org/sleuthkit/autopsy/datamodel/utils/DataSourceLoader.java index 0c1329d9f6..18c762d073 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/utils/DataSourceLoader.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/utils/DataSourceLoader.java @@ -1,16 +1,16 @@ /* - * + * * Autopsy Forensic Browser - * + * * Copyright 2018 Basis Technology Corp. * Contact: carrier sleuthkit 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. @@ -30,10 +30,10 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.datamodel.TskCoreException; /** - * Encapsulates logic required to create a mapping of data sources in the + * Encapsulates logic required to create a mapping of data sources in the * current case to their data source IDs. - * - * Intended to be used within the context of a SwingWorker or other background + * + * Intended to be used within the context of a SwingWorker or other background * thread. */ public class DataSourceLoader { @@ -46,8 +46,7 @@ public class DataSourceLoader { //try block releases resources - exceptions are handled in done() try ( SleuthkitCase.CaseDbQuery query = tskDb.executeQuery(SELECT_DATA_SOURCES_LOGICAL); - ResultSet resultSet = query.getResultSet() - ) { + ResultSet resultSet = query.getResultSet()) { while (resultSet.next()) { Long objectId = resultSet.getLong(1); String dataSourceName = resultSet.getString(2); @@ -56,7 +55,7 @@ public class DataSourceLoader { } } - private void loadImageSources(SleuthkitCase tskDb, Map dataSouceMap) throws SQLException, TskCoreException { + private void loadImageSources(SleuthkitCase tskDb, Map dataSourceMap) throws SQLException, TskCoreException { //try block releases resources - exceptions are handled in done() try ( SleuthkitCase.CaseDbQuery query = tskDb.executeQuery(SELECT_DATA_SOURCES_IMAGE); @@ -64,21 +63,24 @@ public class DataSourceLoader { while (resultSet.next()) { Long objectId = resultSet.getLong(1); - String dataSourceName = resultSet.getString(2); - File image = new File(dataSourceName); - String dataSourceNameTrimmed = image.getName(); - dataSouceMap.put(objectId, dataSourceNameTrimmed); + if (!dataSourceMap.containsKey(objectId)) { + String dataSourceName = resultSet.getString(2); + File image = new File(dataSourceName); + String dataSourceNameTrimmed = image.getName(); + dataSourceMap.put(objectId, dataSourceNameTrimmed); + } } } } /** * Get a map of data source Ids to their string names for the current case. - * + * * @return Map of Long (id) to String (name) + * * @throws NoCurrentCaseException * @throws TskCoreException - * @throws SQLException + * @throws SQLException */ public Map getDataSourceMap() throws NoCurrentCaseException, TskCoreException, SQLException { Map dataSouceMap = new HashMap<>();