diff --git a/src/main/java/com/rarchives/ripme/ui/MainWindow.java b/src/main/java/com/rarchives/ripme/ui/MainWindow.java index dde03dc5..cda82eb0 100644 --- a/src/main/java/com/rarchives/ripme/ui/MainWindow.java +++ b/src/main/java/com/rarchives/ripme/ui/MainWindow.java @@ -536,7 +536,7 @@ public final class MainWindow implements Runnable, RipStatusHandler { setLogLevel(configLogLevelCombobox.getSelectedItem().toString()); configSaveDirLabel = new JLabel(); try { - String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory().toString())); + String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory())); configSaveDirLabel.setText(workingDir); configSaveDirLabel.setForeground(Color.BLUE); configSaveDirLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); @@ -920,21 +920,21 @@ public final class MainWindow implements Runnable, RipStatusHandler { configSaveDirButton.addActionListener(arg0 -> { UIManager.put("FileChooser.useSystemExtensionHiding", false); JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory().toString()); + LOGGER.debug("select save directory, current is:" + Utils.getWorkingDirectory()); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = jfc.showDialog(null, "select directory"); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } - File chosenFile = jfc.getSelectedFile(); - String chosenPath; + Path chosenPath; try { - chosenPath = chosenFile.getCanonicalPath(); + chosenPath = jfc.getSelectedFile().toPath(); } catch (Exception e) { LOGGER.error("Error while getting selected path: ", e); return; } configSaveDirLabel.setText(Utils.shortenPath(chosenPath)); - Utils.setConfigString("rips.directory", chosenPath); + Utils.setConfigString("rips.directory", chosenPath.toString()); }); configUrlFileChooserButton.addActionListener(arg0 -> { UIManager.put("FileChooser.useSystemExtensionHiding", false); @@ -1471,7 +1471,7 @@ public final class MainWindow implements Runnable, RipStatusHandler { statusProgress.setVisible(false); openButton.setVisible(true); Path f = rsc.dir; - String prettyFile = Utils.shortenPath(f.toFile()); + String prettyFile = Utils.shortenPath(f); openButton.setText(Utils.getLocalizedString("open") + prettyFile); mainFrame.setTitle("RipMe v" + UpdateUtils.getThisJarVersion()); try { diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 5ceb361b..29c86adc 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -168,11 +168,10 @@ public class UpdateUtils { logger.error("Error while updating: ", e); } } else { - logger.debug("This version (" + UpdateUtils.getThisJarVersion() - + ") is the same or newer than the website's version (" + latestVersion + ")"); + logger.info("Running version (" + UpdateUtils.getThisJarVersion() + + ") is not older than release (" + latestVersion + ")"); configUpdateLabel.setText("v" + UpdateUtils.getThisJarVersion() + " is the latest version"); - logger.debug("Running latest version: " + UpdateUtils.getThisJarVersion()); } } diff --git a/src/main/java/com/rarchives/ripme/utils/Utils.java b/src/main/java/com/rarchives/ripme/utils/Utils.java index 97b2f752..e84e7973 100644 --- a/src/main/java/com/rarchives/ripme/utils/Utils.java +++ b/src/main/java/com/rarchives/ripme/utils/Utils.java @@ -438,21 +438,23 @@ public class Utils { * @return The simplified path to the file. */ public static String shortenPath(String path) { - return shortenPath(new File(path)); + return shortenPath(path); } /** * Shortens the path to a file * - * @param file File object that you want the shortened path of. + * @param path File object that you want the shortened path of. * @return The simplified path to the file. */ - public static String shortenPath(File file) { - String path = removeCWD(file.toPath()); - if (path.length() < SHORTENED_PATH_LENGTH * 2) { - return path; + public static String shortenPath(Path path) { + Path prettyPath = path.normalize(); + if (prettyPath.toString().length() < SHORTENED_PATH_LENGTH * 2) { + return prettyPath.toString(); } - return path.substring(0, SHORTENED_PATH_LENGTH) + "..." + path.substring(path.length() - SHORTENED_PATH_LENGTH); + return prettyPath.toString().substring(0, SHORTENED_PATH_LENGTH) + + "..." + + prettyPath.toString().substring(prettyPath.toString().length() - SHORTENED_PATH_LENGTH); } /**