Skip to content

Commit

Permalink
Refactor Config#mkdir and #mkAppDataDir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cbeams committed Feb 25, 2020
1 parent de537f0 commit 303eade
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
Expand Down

0 comments on commit 303eade

Please sign in to comment.