From 303eadec39c30b83bbd3c8e49fdec4eba7063a75 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Tue, 25 Feb 2020 11:22:11 +0100 Subject: [PATCH] Refactor Config#mkdir and #mkAppDataDir This is a pure refactoring that renames and inlines variables to tighten up and make more consistent the implementation of these two methods. It is done in preparation for a subsequent substantive change that fixes a bug. --- .../src/main/java/bisq/common/config/Config.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index dac6afe545c..2222ce03313 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -797,14 +797,13 @@ private static File tempUserDataDir() { * nothing if the directory already exists. * @return the given directory, now guaranteed to exist */ - private static File mkAppDataDir(File appDataDir) { - Path path = appDataDir.toPath(); + private static File mkAppDataDir(File dir) { try { - Files.createDirectories(path); + Files.createDirectories(dir.toPath()); } catch (IOException ex) { - throw new UncheckedIOException(format("Application data directory '%s' could not be created", path), ex); + throw new UncheckedIOException(format("Application data directory '%s' could not be created", dir), ex); } - return appDataDir; + return dir; } /** @@ -815,11 +814,10 @@ private static File mkAppDataDir(File appDataDir) { private static File mkdir(File parent, String child) { File dir = new File(parent, child); if (!dir.exists()) { - Path path = dir.toPath(); try { - Files.createDirectory(path); + Files.createDirectory(dir.toPath()); } catch (IOException ex) { - throw new UncheckedIOException(format("Directory '%s' could not be created", path), ex); + throw new UncheckedIOException(format("Directory '%s' could not be created", dir), ex); } } return dir;