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