mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 00:08:51 -05:00
Fix extract tool selection feature
This commit is contained in:
parent
94a3ef60a8
commit
b07371a62a
@ -1,9 +1,16 @@
|
||||
package net.filebot.archive;
|
||||
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import net.filebot.vfs.FileInfo;
|
||||
|
||||
public class FileMapper implements ExtractOutProvider {
|
||||
|
||||
@ -39,4 +46,13 @@ public class FileMapper implements ExtractOutProvider {
|
||||
|
||||
return new FileOutputStream(outputFile);
|
||||
}
|
||||
|
||||
public FileFilter newPathFilter(Collection<FileInfo> selection) {
|
||||
return newPathFilter(selection.stream().map(FileInfo::getPath).collect(toSet()));
|
||||
}
|
||||
|
||||
public FileFilter newPathFilter(Set<String> selection) {
|
||||
return f -> selection.contains(getOutputFile(f).getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class ExtractTool extends Tool<TableModel> {
|
||||
outputMapping.add(new SimpleFileInfo(outputPath.getPath(), it.getLength()));
|
||||
}
|
||||
|
||||
final Set<FileInfo> selection = new TreeSet<FileInfo>();
|
||||
Set<FileInfo> selection = new TreeSet<FileInfo>();
|
||||
for (FileInfo future : outputMapping) {
|
||||
if (filter == null || filter.accept(future.toFile())) {
|
||||
selection.add(future);
|
||||
@ -246,13 +246,7 @@ class ExtractTool extends Tool<TableModel> {
|
||||
archive.extract(outputMapper.getOutputDir());
|
||||
} else {
|
||||
// extract files selected by the given filter
|
||||
archive.extract(outputMapper.getOutputDir(), new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File entry) {
|
||||
return selection.contains(outputMapper.getOutputFile(entry));
|
||||
}
|
||||
});
|
||||
archive.extract(outputMapper.getOutputDir(), outputMapper.newPathFilter(selection));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user