mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Fix excluded file count
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl;
|
||||
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ResultStatistic;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileFilter {
|
||||
static boolean accept(File pathName, String[] fileExtensions) {
|
||||
return StringUtils.endsWithAny(pathName.getAbsolutePath().toLowerCase(), fileExtensions)
|
||||
&& Config.getInstance().getIncludePattern().matcher(pathName.getName()).matches();
|
||||
if (StringUtils.endsWithAny(pathName.getAbsolutePath().toLowerCase(), fileExtensions)
|
||||
&& Config.getInstance().getIncludePattern().matcher(pathName.getName()).matches()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ResultStatistic.getInstance().excluded();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ public abstract class AttributeUpdaterKernel {
|
||||
|
||||
protected final FileCollector collector;
|
||||
protected final FileProcessor processor;
|
||||
protected final ResultStatistic statistic = new ResultStatistic();
|
||||
protected final ResultStatistic statistic = ResultStatistic.getInstance();
|
||||
private final ExecutorService executor = Executors.newFixedThreadPool(Config.getInstance().getThreads());
|
||||
|
||||
private static ProgressBarBuilder pbBuilder() {
|
||||
protected ProgressBarBuilder pbBuilder() {
|
||||
return new ProgressBarBuilder()
|
||||
.setStyle(ProgressBarStyle.ASCII)
|
||||
.setUpdateIntervalMillis(250)
|
||||
|
||||
@@ -7,6 +7,7 @@ import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.AttributeConfig;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileAttribute;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileInfoDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -22,6 +23,12 @@ public class CoherentAttributeUpdaterKernel extends AttributeUpdaterKernel {
|
||||
super(collector, processor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProgressBarBuilder pbBuilder() {
|
||||
return super.pbBuilder()
|
||||
.setUnit(" directories", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -43,10 +50,17 @@ public class CoherentAttributeUpdaterKernel extends AttributeUpdaterKernel {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Update files in directory, if possible, with the same {@link AttributeConfig}.
|
||||
* If {@link Config#isForceCoherent()} then there will be no changes to the file if they don't match the same config.
|
||||
* Otherwise, the default behaviour is executed.
|
||||
* This method is called by the executor and is run in parallel.
|
||||
*
|
||||
* @param file directory containing files
|
||||
*/
|
||||
@Override
|
||||
void process(File file) {
|
||||
// TODO: Implement level crawl if coherence is not possible on user entered depth
|
||||
// IMPL idea: recursive method call, cache needs to be implemented
|
||||
List<FileInfoDto> fileInfos = collector.loadFiles(file.getAbsolutePath())
|
||||
.stream().map(FileInfoDto::new)
|
||||
.collect(Collectors.toList());
|
||||
@@ -85,7 +99,7 @@ public class CoherentAttributeUpdaterKernel extends AttributeUpdaterKernel {
|
||||
});
|
||||
}
|
||||
|
||||
for(FileInfoDto fileInfo: fileInfos) {
|
||||
for (FileInfoDto fileInfo : fileInfos) {
|
||||
statistic.total();
|
||||
if (Config.getInstance().isForceCoherent()) {
|
||||
super.process(fileInfo.getFile());
|
||||
|
||||
@@ -4,6 +4,7 @@ import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.FileCollector;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.FileProcessor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -16,6 +17,12 @@ public class DefaultAttributeUpdaterKernel extends AttributeUpdaterKernel {
|
||||
super(collector, processor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProgressBarBuilder pbBuilder() {
|
||||
return super.pbBuilder()
|
||||
.setUnit(" files", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user