Add support for multiple library paths

This commit is contained in:
RatzzFatzz
2025-12-29 00:12:28 +01:00
parent be004e6146
commit 1165dd8380
5 changed files with 19 additions and 10 deletions

View File

@@ -26,7 +26,7 @@ public class CoherentAttributeUpdater extends SingleFileAttributeUpdater {
}
protected List<File> getFiles() {
return Arrays.stream(config.getLibraryPaths())
return Arrays.stream(config.getLibraryPath())
.flatMap(path -> fileProcessor.loadDirectory(path.getPath(), config.getCoherent()).stream())
.toList();
}

View File

@@ -24,7 +24,7 @@ public class SingleFileAttributeUpdater extends AttributeUpdater {
@Override
protected List<File> getFiles() {
return Arrays.stream(config.getLibraryPaths())
return Arrays.stream(config.getLibraryPath())
.flatMap(path -> fileProcessor.loadFiles(path.getPath()).stream())
.toList();
}

View File

@@ -2,10 +2,12 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.validation;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.Arrays;
@Slf4j
public class ValidFileValidator implements ConstraintValidator<ValidFile, File[]> {
@Override
public void initialize(ValidFile constraintAnnotation) {
@@ -13,6 +15,13 @@ public class ValidFileValidator implements ConstraintValidator<ValidFile, File[]
@Override
public boolean isValid(File[] files, ConstraintValidatorContext context) {
return files != null && files.length > 0 && Arrays.stream(files).allMatch(File::exists);
if (files == null || files.length == 0) return false;
for (File file: files) {
if (!file.exists()) {
log.error("{} does not exist", file.getPath());
return false;
}
}
return true;
}
}

View File

@@ -30,7 +30,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
@ValidFile(message = "does not exist")
@CommandLine.Parameters(description = "paths to library", arity = "1..*")
private File[] libraryPaths;
private File[] libraryPath;
@Option(names = {"-a", "--attribute-config"}, arity = "1..*", converter = AttributeConfigConverter.class,
description = "List of audio:subtitle pairs for matching defaults in order (e.g. jpn:eng jpn:ger)")
@@ -91,7 +91,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
return new StringJoiner(", ", InputConfig.class.getSimpleName() + "[", "]")
.add("configPath=" + configPath)
.add("spec=" + spec)
.add("libraryPath=" + libraryPaths)
.add("libraryPath=" + libraryPath)
.add("attributeConfig=" + Arrays.toString(attributeConfig))
.add("mkvToolNix=" + mkvToolNix)
.add("safeMode=" + safeMode)