mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-10 17:55:57 +01:00
Fix filter-date format & add test for filter-date
This commit is contained in:
@@ -33,7 +33,7 @@ public class FileFilter {
|
|||||||
|
|
||||||
if (!hasMatchingPattern(pathName)
|
if (!hasMatchingPattern(pathName)
|
||||||
|| isExcluded(pathName, new HashSet<>(excluded))
|
|| isExcluded(pathName, new HashSet<>(excluded))
|
||||||
|| lastExecutionHandler != null && !isNewOrChanged(pathName)
|
|| lastExecutionHandler != null && !isNewer(pathName, lastExecutionHandler.get(pathName.getAbsolutePath()))
|
||||||
|| !isNewer(pathName, filterDate)) {
|
|| !isNewer(pathName, filterDate)) {
|
||||||
log.debug("Excluded {}", pathName);
|
log.debug("Excluded {}", pathName);
|
||||||
ResultStatistic.getInstance().excluded();
|
ResultStatistic.getInstance().excluded();
|
||||||
@@ -83,9 +83,4 @@ public class FileFilter {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNewOrChanged(File pathname) {
|
|
||||||
Instant lastExecutionDate = lastExecutionHandler.get(pathname.getAbsolutePath());
|
|
||||||
return lastExecutionDate == null || isNewer(pathname, lastExecutionDate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
|||||||
// TODO: implement usage
|
// TODO: implement usage
|
||||||
@Option(names = {"-n", "--only-new-files"}, description = "ignores all files unchanged and previously processed")
|
@Option(names = {"-n", "--only-new-files"}, description = "ignores all files unchanged and previously processed")
|
||||||
private boolean onlyNewFiles;
|
private boolean onlyNewFiles;
|
||||||
@Option(names = {"-d", "--filter-date"}, defaultValue = Option.NULL_VALUE, description = "only consider files created newer than entered date (format: \"dd.MM.yyyy-HH:mm:ss\")")
|
@Option(names = {"-d", "--filter-date"}, defaultValue = Option.NULL_VALUE, description = "only consider files created newer than entered date (following ISO-8601 yyyy-MM-ddTHH:mm:ss.sssZ)")
|
||||||
private Instant filterDate;
|
private Instant filterDate;
|
||||||
@Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern")
|
@Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern")
|
||||||
private Pattern includePattern;
|
private Pattern includePattern;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package at.pcgamingfreaks.mkvaudiosubtitlechanger.config;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.CommandRunner;
|
||||||
|
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.validation.ValidationExecutionStrategy;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import picocli.CommandLine;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import static at.pcgamingfreaks.mkvaudiosubtitlechanger.util.PathUtils.TEST_FILE;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class PicoCliTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadFilterDate() {
|
||||||
|
CommandRunner underTest = new CommandRunner();
|
||||||
|
new CommandLine(underTest)
|
||||||
|
.setExecutionStrategy(new ValidationExecutionStrategy())
|
||||||
|
.parseArgs("-d", "2012-12-12T12:12:12.00Z", TEST_FILE);
|
||||||
|
assertEquals(Instant.parse("2012-12-12T12:12:12.00Z"), underTest.getConfig().getFilterDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user