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