19 package org.sleuthkit.autopsy.casemodule;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.logging.Level;
24 import org.openide.util.NbBundle;
41 class AddLocalFilesTask
implements Runnable {
43 private static final Logger LOGGER = Logger.getLogger(AddLocalFilesTask.class.getName());
44 private final String deviceId;
45 private final String rootVirtualDirectoryName;
46 private final Host host;
47 private final List<String> localFilePaths;
48 private final DataSourceProcessorProgressMonitor progress;
49 private final DataSourceProcessorCallback callback;
50 private final boolean createTimestamp;
51 private final boolean accessTimestamp;
52 private final boolean modifiedTimestamp;
80 AddLocalFilesTask(String deviceId, String rootVirtualDirectoryName, List<String> localFilePaths, Host host,
boolean createTimestamp,
81 boolean accessTimestamp,
boolean modifiedTimestamp, DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback callback) {
82 this.deviceId = deviceId;
83 this.rootVirtualDirectoryName = rootVirtualDirectoryName;
84 this.localFilePaths = localFilePaths;
86 this.createTimestamp = createTimestamp;
87 this.accessTimestamp = accessTimestamp;
88 this.modifiedTimestamp = modifiedTimestamp;
89 this.callback = callback;
90 this.progress = progressMonitor;
100 List<Content> newDataSources =
new ArrayList<>();
101 List<String> errors =
new ArrayList<>();
103 progress.setIndeterminate(
true);
104 FileManager fileManager = Case.getCurrentCaseThrows().getServices().getFileManager();
105 LocalFilesDataSource newDataSource = fileManager.addLocalFilesDataSource(deviceId, rootVirtualDirectoryName,
"", host, localFilePaths, createTimestamp,
106 accessTimestamp, modifiedTimestamp,
new ProgressUpdater());
107 newDataSources.add(newDataSource);
108 }
catch (TskDataException | TskCoreException | NoCurrentCaseException ex) {
109 errors.add(ex.getMessage());
110 LOGGER.log(Level.SEVERE, String.format(
"Failed to add datasource: %s", ex.getMessage()), ex);
112 DataSourceProcessorCallback.DataSourceProcessorResult result;
113 if (!errors.isEmpty()) {
114 result = DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS;
116 result = DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS;
118 callback.done(result, errors, newDataSources);
137 if (count % 10 == 0) {
138 progress.setProgressText(NbBundle.getMessage(
this.getClass(),
139 "AddLocalFilesTask.localFileAdd.progress.text",
140 file.getParentPath(),
void fileAdded(final AbstractFile file)