mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Fix last-execution file saving
This commit is contained in:
@@ -72,17 +72,22 @@ public class Config {
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", Config.class.getSimpleName() + "[", "]")
|
||||
.add("parser=" + parser).add("\n")
|
||||
.add("formatter=" + formatter).add("\n")
|
||||
.add("configPath=" + configPath).add("\n")
|
||||
.add("libraryPath=" + libraryPath).add("\n")
|
||||
.add("isSafeMode=" + safeMode).add("\n")
|
||||
.add("forcedKeywords=" + forcedKeywords).add("\n")
|
||||
.add("commentaryKeywords=" + commentaryKeywords).add("\n")
|
||||
.add("excludedDirectories=" + excludedDirectories).add("\n")
|
||||
.add("threadCount=" + threads).add("\n")
|
||||
.add("includePattern=" + includePattern).add("\n")
|
||||
.add("mkvToolNixPath='" + mkvToolNix + "'").add("\n")
|
||||
.add("parser=" + parser)
|
||||
.add("formatter=" + formatter)
|
||||
.add("configPath=" + configPath)
|
||||
.add("libraryPath=" + libraryPath)
|
||||
.add("mkvToolNix=" + mkvToolNix)
|
||||
.add("threads=" + threads)
|
||||
.add("includePattern=" + includePattern)
|
||||
.add("safeMode=" + safeMode)
|
||||
.add("coherent=" + coherent)
|
||||
.add("forceCoherent=" + forceCoherent)
|
||||
.add("onlyNewFiles=" + onlyNewFiles)
|
||||
.add("filterDate=" + filterDate)
|
||||
.add("forcedKeywords=" + forcedKeywords)
|
||||
.add("commentaryKeywords=" + commentaryKeywords)
|
||||
.add("excludedDirectories=" + excludedDirectories)
|
||||
.add("preferredSubtitles=" + preferredSubtitles)
|
||||
.add("attributeConfig=" + attributeConfig)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@@ -6,17 +6,18 @@ import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ConfigProperty;
|
||||
import at.pcgamingfreaks.yaml.YAML;
|
||||
import at.pcgamingfreaks.yaml.YamlKeyNotFoundException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public abstract class ConfigValidator<FieldType> {
|
||||
protected final ConfigProperty property;
|
||||
@@ -157,4 +158,13 @@ public abstract class ConfigValidator<FieldType> {
|
||||
public int getWeight() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(", ", ConfigValidator.class.getSimpleName() + "[", "]")
|
||||
.add("property=" + property)
|
||||
.add("required=" + required)
|
||||
.add("defaultValue=" + defaultValue)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Date;
|
||||
@Slf4j
|
||||
public class DateValidator extends ConfigValidator<Date> {
|
||||
private static final Date INVALID_DATE = new Date(0);
|
||||
private static final Date DEFAULT_DATE = new Date(1);
|
||||
private static final Date DEFAULT_DATE = new Date(1000);
|
||||
|
||||
public DateValidator(ConfigProperty property, boolean required) {
|
||||
super(property, required, null);
|
||||
@@ -37,7 +37,7 @@ public class DateValidator extends ConfigValidator<Date> {
|
||||
return DEFAULT_DATE;
|
||||
}
|
||||
YAML yaml = new YAML(lastExecutionFile);
|
||||
return parse(yaml.getString(Config.getInstance().getLibraryPath().getAbsolutePath(), DateUtils.convert(DEFAULT_DATE)));
|
||||
return parse(yaml.getString(Config.getInstance().getLibraryPath().getAbsolutePath().replace("\\", "/"), DateUtils.convert(DEFAULT_DATE)));
|
||||
} catch (YamlInvalidContentException | IOException e) {
|
||||
log.error("Couldn't open last-execution.properties");
|
||||
return INVALID_DATE;
|
||||
|
||||
@@ -150,6 +150,10 @@ public abstract class AttributeUpdaterKernel {
|
||||
}
|
||||
|
||||
protected void endProcess() {
|
||||
if (Config.getInstance().isSafeMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String filePath = AppDirsFactory.getInstance().getUserConfigDir(ProjectUtil.getProjectName(), null, null);
|
||||
|
||||
@@ -162,7 +166,7 @@ public abstract class AttributeUpdaterKernel {
|
||||
}
|
||||
|
||||
YAML yaml = new YAML(lastExecutionFile);
|
||||
yaml.set(Config.getInstance().getLibraryPath().getAbsolutePath(), DateUtils.convert(new Date()));
|
||||
yaml.set(Config.getInstance().getLibraryPath().getAbsolutePath().replace("\\", "/"), DateUtils.convert(new Date()));
|
||||
yaml.save(lastExecutionFile);
|
||||
} catch (IOException | YamlInvalidContentException e) {
|
||||
log.error("last-execution.yml could not be created: ", e); // TODO
|
||||
|
||||
Reference in New Issue
Block a user