diff --git a/rulesets/java-sheepit.xml b/rulesets/java-sheepit.xml
index 839f362..5373821 100644
--- a/rulesets/java-sheepit.xml
+++ b/rulesets/java-sheepit.xml
@@ -54,7 +54,11 @@
-
+
+
+
+
+
diff --git a/src/main/java/com/sheepit/client/Client.java b/src/main/java/com/sheepit/client/Client.java
index af52717..01d571c 100644
--- a/src/main/java/com/sheepit/client/Client.java
+++ b/src/main/java/com/sheepit/client/Client.java
@@ -53,6 +53,7 @@ import com.sheepit.client.datamodel.client.Error.ServerCode;
import com.sheepit.client.datamodel.client.Error.Type;
import com.sheepit.client.datamodel.server.Chunk;
import com.sheepit.client.exception.SheepItException;
+import com.sheepit.client.exception.SheepItExceptionCacheDirDeleted;
import com.sheepit.client.exception.SheepItExceptionNoRendererAvailable;
import com.sheepit.client.exception.SheepItExceptionNoRightToRender;
import com.sheepit.client.exception.SheepItExceptionNoSession;
@@ -770,6 +771,9 @@ import okhttp3.HttpUrl;
else if (e instanceof SheepItExceptionNoWritePermission) {
return Error.Type.NO_WRITE_PERMISSION;
}
+ else if (e instanceof SheepItExceptionCacheDirDeleted) {
+ return Type.CACHE_DIR_DELETED;
+ }
else {
return Error.Type.UNKNOWN;
}
@@ -838,6 +842,7 @@ import okhttp3.HttpUrl;
this.serverRequest,
this.gui,
this.log,
+ this.directoryManager,
this.directoryManager.getActualStoragePathFor(chunk),
chunk.getMd5(),
String.format(LOCALE, "%s?chunk=%s", this.serverRequest.getPage("download-chunk"), chunk.getId())
@@ -858,14 +863,21 @@ import okhttp3.HttpUrl;
}
}
}
- catch (ExecutionException | InterruptedException | TimeoutException e) {
-
- executor.shutdown();
+ catch (ExecutionException e) {
+ if (e.getCause() instanceof SheepItException) {
+ throw (SheepItException)e.getCause();
+ }
+ else {
+ this.log.error("downloadChunks failed " + e.getCause());
+ }
+ }
+ catch (InterruptedException | TimeoutException e) {
return Type.DOWNLOAD_FILE;
}
-
+ finally {
+ executor.shutdown();
+ }
- executor.shutdown();
return Type.OK;
}
diff --git a/src/main/java/com/sheepit/client/datamodel/client/Error.java b/src/main/java/com/sheepit/client/datamodel/client/Error.java
index e134cbf..002562d 100644
--- a/src/main/java/com/sheepit/client/datamodel/client/Error.java
+++ b/src/main/java/com/sheepit/client/datamodel/client/Error.java
@@ -59,6 +59,7 @@ public class Error {
CANNOT_READ_FILE(30),
DETECT_DEVICE_ERROR(31),
COLOR_MANAGEMENT_ERROR(33),
+ CACHE_DIR_DELETED(35),
// internal error handling
NO_SPACE_LEFT_ON_DEVICE(100),
@@ -206,7 +207,7 @@ public class Error {
case RENDERER_KILLED_BY_USER_INCOMPATIBLE_PROCESS:
return "Stopped rendering: The incompatible user-specified process is running.";
case SESSION_DISABLED:
- return "The server has disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc).";
+ return "The server has disabled your session. Your client may have generated a broken frame (GPU not compatible, not enough RAM/VRAM, etc) or your cache directory is not longer available.";
case RENDERER_NOT_AVAILABLE:
return "The official Blender builds don't support rendering on this hardware.";
case MISSING_RENDERER:
@@ -237,6 +238,8 @@ public class Error {
return "There was an error with your GPU or driver. Please ensure you have the latest driver and don't run extreme over/underclockings.";
case COLOR_MANAGEMENT_ERROR:
return "There was an error with the Color management. Please ensure you didn't set a weird OCIO config. Or the project might use an unsupported Color management configuration.";
+ case CACHE_DIR_DELETED:
+ return "Cache directory is missing, the client is now DEAD";
default:
return in.toString();
}
diff --git a/src/main/java/com/sheepit/client/exception/SheepItExceptionCacheDirDeleted.java b/src/main/java/com/sheepit/client/exception/SheepItExceptionCacheDirDeleted.java
new file mode 100644
index 0000000..e038735
--- /dev/null
+++ b/src/main/java/com/sheepit/client/exception/SheepItExceptionCacheDirDeleted.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2025 Laurent CLOUET
+ * Author Laurent CLOUET
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package com.sheepit.client.exception;
+
+public class SheepItExceptionCacheDirDeleted extends SheepItException {
+ public SheepItExceptionCacheDirDeleted() {
+ super();
+ }
+
+ public SheepItExceptionCacheDirDeleted(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/sheepit/client/network/DownloadManager.java b/src/main/java/com/sheepit/client/network/DownloadManager.java
index 339ee8e..cea2f6e 100644
--- a/src/main/java/com/sheepit/client/network/DownloadManager.java
+++ b/src/main/java/com/sheepit/client/network/DownloadManager.java
@@ -18,11 +18,14 @@
*/
package com.sheepit.client.network;
+import com.sheepit.client.config.DirectoryManager;
import com.sheepit.client.datamodel.client.Error;
+import com.sheepit.client.exception.SheepItExceptionCacheDirDeleted;
import com.sheepit.client.ui.Gui;
import com.sheepit.client.logger.Log;
import com.sheepit.client.utils.Utils;
import com.sheepit.client.exception.SheepItException;
+import lombok.AllArgsConstructor;
import java.io.File;
import java.io.IOException;
@@ -33,28 +36,20 @@ import java.nio.file.Path;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-public class DownloadManager {
+@AllArgsConstructor public class DownloadManager {
private static int maxDownloadFileAttempts = 5;
// global objects
private ServerRequest serverRequest;
private Gui gui;
private Log log;
+ private DirectoryManager directoryManager;
// task specific objects
private String local_target;
private String md5; // expected md5 of the file, for check purpose
private String remote; // remote url
- public DownloadManager(ServerRequest serverRequest, Gui gui, Log log, String local_target, String md5, String remote) {
- this.serverRequest = serverRequest;
- this.gui = gui;
- this.log = log;
- this.local_target = local_target;
- this.md5 = md5;
- this.remote = remote;
- }
-
public Error.Type download() throws SheepItException {
File local_path_file = new File(this.local_target);
@@ -175,7 +170,7 @@ public class DownloadManager {
return new File(this.local_target + ".partial").exists();
}
- private void createLock() {
+ private void createLock() throws SheepItExceptionCacheDirDeleted {
try {
File file = new File(this.local_target + ".partial");
file.createNewFile();
@@ -193,6 +188,16 @@ public class DownloadManager {
this.log.error("DownloadManager::createLock checking path info " + test_path + " exists? " + (new File(test_path).exists() ? "yes" : "no") + " is writeable? " + (Files.isWritable(Path.of(test_path)) ? "yes" : "no"));
current_path = test_path;
}
+
+ File cache_dir = new File(this.local_target).getParentFile();
+ if (cache_dir.exists() == false) {
+ this.log.error("DownloadManager::createLock cache-dir has been deleted, it should not happen, park the client");
+ // it shouldn't happen, the client need a cache dir
+
+ // 2 solutions: re-create the cache dir or park the client.
+ // we don't know why the cache dir was deleted so -> park the client
+ throw new SheepItExceptionCacheDirDeleted();
+ }
}
}