mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Add safe-mode
This commit is contained in:
@@ -36,8 +36,12 @@ public class AttributeUpdaterKernel {
|
||||
executor.awaitTermination(1, TimeUnit.DAYS);
|
||||
runtime = System.currentTimeMillis() - beforeTimer;
|
||||
|
||||
System.out.printf("%nFiles changed: %s%n", filesChangedAmount);
|
||||
System.out.printf("Files not changed: %s%n", filesNotChangedAmount);
|
||||
System.out.printf("%nFiles %schanged: %s%n",
|
||||
ConfigUtil.getInstance().isSafeMode() ? "would " : "",
|
||||
filesChangedAmount);
|
||||
System.out.printf("Files %s not changed: %s%n",
|
||||
ConfigUtil.getInstance().isSafeMode() ? "would " : "",
|
||||
filesNotChangedAmount);
|
||||
System.out.printf("Runtime: %ss%n", runtime / 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ public class Main {
|
||||
options.addRequiredOption("l", "library", true, "path to library");
|
||||
options.addOption("c", "config", false, "path to config");
|
||||
options.addOption("t", "threads", true, "thread count");
|
||||
options.addOption("s", "safe-mode", false, "Test run (no files will be changes)");
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
@@ -56,6 +57,7 @@ public class Main {
|
||||
configUtil.loadConfig(cmd.getOptionValue("config", "config.yaml")); // use cmd input
|
||||
configUtil.setLibraryPath(cmd.getOptionValue("library"));
|
||||
if (cmd.hasOption("threads")) configUtil.setThreadCount(parseInt(cmd.getOptionValue("threads")));
|
||||
configUtil.setSafeMode(cmd.hasOption("safe-mode"));
|
||||
configUtil.isValid();
|
||||
} catch (ParseException e) {
|
||||
log.error(e);
|
||||
|
||||
@@ -2,6 +2,7 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger.config;
|
||||
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.MKVToolProperties;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.FileAttribute;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.util.ConfigUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -121,7 +122,9 @@ public class ConfigProcessor {
|
||||
return true;
|
||||
}
|
||||
try{
|
||||
if(!ConfigUtil.getInstance().isSafeMode()) {
|
||||
Runtime.getRuntime().exec(stringBuffer.toString());
|
||||
}
|
||||
}catch(IOException e){
|
||||
log.error("Couldn't make changes to file");
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ConfigUtil {
|
||||
@Getter(AccessLevel.NONE)
|
||||
private String mkvtoolnixPath;
|
||||
private String libraryPath;
|
||||
private boolean isSafeMode;
|
||||
|
||||
public static ConfigUtil getInstance() {
|
||||
if(configUtil == null) {
|
||||
|
||||
Reference in New Issue
Block a user