mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-21 13:11:27 +02:00
exec stringarray instead of string, java-21 deprecation.
This commit is contained in:
@@ -470,7 +470,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
queuePanel.setBorder(emptyBorder);
|
queuePanel.setBorder(emptyBorder);
|
||||||
queuePanel.setVisible(false);
|
queuePanel.setVisible(false);
|
||||||
queuePanel.setPreferredSize(new Dimension(300, 250));
|
queuePanel.setPreferredSize(new Dimension(300, 250));
|
||||||
queueListModel = new DefaultListModel();
|
queueListModel = new DefaultListModel<>();
|
||||||
JList queueList = new JList(queueListModel);
|
JList queueList = new JList(queueListModel);
|
||||||
queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
queueList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
QueueMenuMouseListener queueMenuMouseListener;
|
QueueMenuMouseListener queueMenuMouseListener;
|
||||||
@@ -732,7 +732,7 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
private void update() {
|
private void update() {
|
||||||
try {
|
try {
|
||||||
String urlText = ripTextfield.getText().trim();
|
String urlText = ripTextfield.getText().trim();
|
||||||
if (urlText.equals("")) {
|
if (urlText.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!urlText.startsWith("http")) {
|
if (!urlText.startsWith("http")) {
|
||||||
@@ -1499,12 +1499,13 @@ public final class MainWindow implements Runnable, RipStatusHandler {
|
|||||||
*/
|
*/
|
||||||
if (Utils.getConfigBoolean("enable.finish.command", false)) {
|
if (Utils.getConfigBoolean("enable.finish.command", false)) {
|
||||||
try {
|
try {
|
||||||
String commandToRun = Utils.getConfigString("finish.command", "ls");
|
String cmdStr = Utils.getConfigString("finish.command", "ls");
|
||||||
commandToRun = commandToRun.replaceAll("%url%", url);
|
cmdStr = cmdStr.replaceAll("%url%", url);
|
||||||
commandToRun = commandToRun.replaceAll("%path%", f.toAbsolutePath().toString());
|
cmdStr = cmdStr.replaceAll("%path%", f.toAbsolutePath().toString());
|
||||||
|
// java dropped the exec string executor, as the string is only split very trivial.
|
||||||
|
// do the same at the moment, and split, to get rid of java-21 deprecation warning.
|
||||||
|
String[] commandToRun = cmdStr.split(" ");
|
||||||
LOGGER.info("RUnning command " + commandToRun);
|
LOGGER.info("RUnning command " + commandToRun);
|
||||||
// code from:
|
|
||||||
// https://stackoverflow.com/questions/5711084/java-runtime-getruntime-getting-output-from-executing-a-command-line-program
|
|
||||||
Process proc = Runtime.getRuntime().exec(commandToRun);
|
Process proc = Runtime.getRuntime().exec(commandToRun);
|
||||||
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||||
|
|
||||||
|
@@ -222,13 +222,14 @@ public class UpdateUtils {
|
|||||||
public static String createSha256(Path file) {
|
public static String createSha256(Path file) {
|
||||||
try {
|
try {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
InputStream fis = Files.newInputStream(file);
|
try (InputStream fis = Files.newInputStream(file)) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
while (n != -1) {
|
while (n != -1) {
|
||||||
n = fis.read(buffer);
|
n = fis.read(buffer);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
digest.update(buffer, 0, n);
|
digest.update(buffer, 0, n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
byte[] hash = digest.digest();
|
byte[] hash = digest.digest();
|
||||||
@@ -313,7 +314,7 @@ public class UpdateUtils {
|
|||||||
if (shouldLaunch) {
|
if (shouldLaunch) {
|
||||||
// No need to do it during shutdown: the file used will indeed be the new one
|
// No need to do it during shutdown: the file used will indeed be the new one
|
||||||
logger.info("Executing: " + mainFile);
|
logger.info("Executing: " + mainFile);
|
||||||
Runtime.getRuntime().exec("java -jar " + mainFile);
|
Runtime.getRuntime().exec(new String[]{"java", "-jar", mainFile.toString()});
|
||||||
}
|
}
|
||||||
logger.info("Update installed, newer version should be executed upon relaunch");
|
logger.info("Update installed, newer version should be executed upon relaunch");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
Reference in New Issue
Block a user