mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Improve file loading abstraction for attribute updater
This commit is contained in:
@@ -46,9 +46,7 @@ public abstract class AttributeUpdater {
|
||||
statistic.startTimer();
|
||||
|
||||
try (ProgressBar progressBar = pbBuilder().build()) {
|
||||
List<File> files = config.getCoherent() != null
|
||||
? fileProcessor.loadDirectory(config.getLibraryPath().getPath(), config.getCoherent())
|
||||
: fileProcessor.loadFiles(config.getLibraryPath().getPath());
|
||||
List<File> files = getFiles();
|
||||
|
||||
progressBar.maxHint(files.size());
|
||||
progressBar.refresh();
|
||||
@@ -68,6 +66,8 @@ public abstract class AttributeUpdater {
|
||||
statistic.printResult();
|
||||
}
|
||||
|
||||
protected abstract List<File> getFiles();
|
||||
|
||||
/**
|
||||
* Start of the file updating process.
|
||||
* This method is called by the executor and its contents are executed in parallel.
|
||||
|
||||
@@ -24,6 +24,10 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
|
||||
.setUnit(" directories", 1);
|
||||
}
|
||||
|
||||
protected List<File> getFiles() {
|
||||
return fileProcessor.loadDirectory(config.getLibraryPath().getPath(), config.getCoherent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(File rootDir) {
|
||||
if (rootDir.isFile()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import me.tongfei.progressbar.ProgressBarBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class SingleFileAttributeUpdater extends AttributeUpdater {
|
||||
@@ -20,6 +21,12 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
|
||||
.setUnit(" files", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<File> getFiles() {
|
||||
return fileProcessor.loadFiles(config.getLibraryPath().getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(File file) {
|
||||
FileInfo fileInfo = fileProcessor.readAttributes(file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user