diff --git a/CHANGELOG.md b/CHANGELOG.md index cca931c1..351a561a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Renamed settings for Chaturbate's user name and password * Add setting to split recordings by size * Fixed moving of segment recordings on the server (post-processing) +* Minimal browser config is now stored in ctbrec's config directory 3.10.6 ======================== diff --git a/client/src/main/java/ctbrec/ui/ExternalBrowser.java b/client/src/main/java/ctbrec/ui/ExternalBrowser.java index 51a036df..ab1580b0 100644 --- a/client/src/main/java/ctbrec/ui/ExternalBrowser.java +++ b/client/src/main/java/ctbrec/ui/ExternalBrowser.java @@ -1,11 +1,15 @@ package ctbrec.ui; +import static java.nio.charset.StandardCharsets.*; + import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.Socket; +import java.util.Arrays; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.function.Consumer; @@ -47,7 +51,9 @@ public class ExternalBrowser implements AutoCloseable { addProxyConfig(jsonConfig.getJSONObject("config")); - p = new ProcessBuilder(OS.getBrowserCommand()).start(); + File configDir = new File(Config.getInstance().getConfigDir(), "ctbrec-minimal-browser"); + String[] cmdline = OS.getBrowserCommand(configDir.getCanonicalPath()); + p = new ProcessBuilder(cmdline).start(); if (LOG.isTraceEnabled()) { new Thread(new StreamRedirector(p.getInputStream(), System.out)).start(); new Thread(new StreamRedirector(p.getErrorStream(), System.err)).start(); @@ -55,7 +61,7 @@ public class ExternalBrowser implements AutoCloseable { new Thread(new StreamRedirector(p.getInputStream(), OutputStream.nullOutputStream())).start(); new Thread(new StreamRedirector(p.getErrorStream(), OutputStream.nullOutputStream())).start(); } - LOG.debug("Browser started"); + LOG.debug("Browser started: {}", Arrays.toString(cmdline)); connectToRemoteControlSocket(); while (!browserReady) { @@ -68,7 +74,7 @@ public class ExternalBrowser implements AutoCloseable { } else { LOG.debug("Connected to remote control server. Sending config"); } - out.write(jsonConfig.toString().getBytes("utf-8")); + out.write(jsonConfig.toString().getBytes(UTF_8)); out.write('\n'); out.flush(); @@ -116,7 +122,7 @@ public class ExternalBrowser implements AutoCloseable { //LOG.debug("Executing JS {}", javaScript); JSONObject script = new JSONObject(); script.put("execute", javaScript); - out.write(script.toString().getBytes("utf-8")); + out.write(script.toString().getBytes(UTF_8)); out.write('\n'); out.flush(); if(javaScript.equals("quit")) { diff --git a/common/src/main/java/ctbrec/Config.java b/common/src/main/java/ctbrec/Config.java index c943ab92..76eec655 100644 --- a/common/src/main/java/ctbrec/Config.java +++ b/common/src/main/java/ctbrec/Config.java @@ -17,6 +17,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -145,6 +146,17 @@ public class Config { settings.splitRecordingsAfterSecs = settings.splitRecordings; settings.splitRecordings = 0; } + // migrate old config from ctbrec-minimal browser + File oldLocation = new File(OS.getConfigDir().getParentFile(), "ctbrec-minimal-browser"); + if (oldLocation.exists()) { + File newLocation = new File(getConfigDir(), oldLocation.getName()); + try { + LOG.debug("Moving minimal browser config {} --> {}", oldLocation, newLocation); + FileUtils.moveDirectory(oldLocation, newLocation); + } catch (IOException e) { + LOG.error("Couldn't migrate minimal browser config location", e); + } + } } private void makeBackup(File source) {