mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #2496 from sleuthkit/uniqe_extract
Dedupe files in the export file action
This commit is contained in:
commit
c6ccff7f22
@ -23,7 +23,9 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
@ -128,9 +130,14 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get the unique set of files from the list. A user once reported extraction taking
|
||||||
|
* days because it was extracting the same PST file 20k times. They selected 20k
|
||||||
|
* email messages in the tree and chose to extract them. */
|
||||||
|
Set<AbstractFile> uniqueFiles = new HashSet<>(selectedFiles);
|
||||||
|
|
||||||
// make a task for each file
|
// make a task for each file
|
||||||
ArrayList<FileExtractionTask> fileExtractionTasks = new ArrayList<>();
|
ArrayList<FileExtractionTask> fileExtractionTasks = new ArrayList<>();
|
||||||
for (AbstractFile source : selectedFiles) {
|
for (AbstractFile source : uniqueFiles) {
|
||||||
// If there is an attribute name, change the ":". Otherwise the extracted file will be hidden
|
// If there is an attribute name, change the ":". Otherwise the extracted file will be hidden
|
||||||
fileExtractionTasks.add(new FileExtractionTask(source, new File(destinationFolder, source.getId() + "-" + FileUtil.escapeFileName(source.getName()))));
|
fileExtractionTasks.add(new FileExtractionTask(source, new File(destinationFolder, source.getId() + "-" + FileUtil.escapeFileName(source.getName()))));
|
||||||
}
|
}
|
||||||
@ -151,10 +158,8 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @@@ Problems with this code: - does not prevent us from having
|
* This code assumes that each destination is unique. We previously satisfied
|
||||||
* multiple files with the same target name in the task list (in
|
* that by adding the unique ID.
|
||||||
* which case, the first ones are overwritten) Unique Id was added
|
|
||||||
* to set of names before calling this method to deal with that.
|
|
||||||
*/
|
*/
|
||||||
if (task.destination.exists()) {
|
if (task.destination.exists()) {
|
||||||
if (JOptionPane.showConfirmDialog((Component) e.getSource(),
|
if (JOptionPane.showConfirmDialog((Component) e.getSource(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user