From 7b27c084b33e34d9d52ae8ac8092743dcb303c24 Mon Sep 17 00:00:00 2001 From: DaCool <8727384-DaCool@users.noreply.gitlab.com> Date: Wed, 22 Nov 2023 17:10:16 +0000 Subject: [PATCH] Rework getdir functions --- .../com/sheepit/client/Configuration.java | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/sheepit/client/Configuration.java b/src/main/java/com/sheepit/client/Configuration.java index b07f849..1230de9 100644 --- a/src/main/java/com/sheepit/client/Configuration.java +++ b/src/main/java/com/sheepit/client/Configuration.java @@ -219,38 +219,20 @@ import lombok.Data; } } - public void setStorageDir(File dir) { - if (dir != null) { - if (dir.exists() == false) { - dir.mkdir(); - } - this.storageDirectory = dir; - } - } - /** * @return the storage directory or the working directory if the former is not defined */ public File getStorageDir() { - if (this.storageDirectory == null) { - return this.workingDirectory; - } - else { - return this.storageDirectory; - } + return this.storageDirectory == null ? this.workingDirectory : this.storageDirectory; } /** * @return the user specified cache directory or null if it hasn't been specified */ public File getCacheDirForSettings() { - if (this.userHasSpecifiedACacheDir == false) { - return null; - } - else { - // when the user have a cache directory a "sheepit" and "sheepit_binary_cache" is be automaticaly added - return this.workingDirectory.getParentFile(); - } + // when the user has a cache directory specified, + // a "sheepit" and "sheepit_binary_cache" directory is to be automatically created + return this.userHasSpecifiedACacheDir == false ? null : this.workingDirectory.getParentFile(); } /**