Ref: configuration class shouldn't create and handle directory, DirectoryManager should do it

This commit is contained in:
Sheepit Renderfarm
2024-11-20 22:51:06 +00:00
parent 972092f2c1
commit 9cb1fe62cb
8 changed files with 233 additions and 218 deletions

View File

@@ -96,7 +96,7 @@ import okhttp3.HttpUrl;
this.server = new Server(url, this.configuration, this);
this.log = Log.getInstance(this.configuration);
this.gui = gui;
this.directoryManager = new DirectoryManager(this.configuration, this.log);
this.directoryManager = new DirectoryManager(this.configuration);
this.renderingJob = null;
this.previousJob = null;
this.jobsToValidate = new ArrayBlockingQueue<>(5);
@@ -171,13 +171,13 @@ import okhttp3.HttpUrl;
step = log.newCheckPoint();
this.log.info("OS: " + OS.getOS().getVersion() + " " + System.getProperty("os.arch"));
this.log.info(configuration.toString());
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
this.log.info(logline);
}
sendError(step, null, Type.OK);
// Check integrity of all files in the working directories
this.configuration.cleanWorkingDirectory();
this.directoryManager.cleanWorkingDirectory();
this.startTime = new Date().getTime();
this.server.start(); // for staying alive
@@ -435,7 +435,7 @@ import okhttp3.HttpUrl;
}
}
this.configuration.removeWorkingDirectory();
this.directoryManager.removeWorkingDirectory();
if (this.server == null) {
return 0;
@@ -703,7 +703,7 @@ import okhttp3.HttpUrl;
downloadRet = this.downloadExecutable(ajob);
if (downloadRet != Error.Type.OK) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
this.log.error("Client::work problem with downloadExecutable (ret " + downloadRet + ")");
@@ -713,7 +713,7 @@ import okhttp3.HttpUrl;
downloadRet = this.downloadSceneFile(ajob);
if (downloadRet != Error.Type.OK) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
this.log.error("Client::work problem with downloadSceneFile (ret " + downloadRet + ")");
@@ -723,7 +723,7 @@ import okhttp3.HttpUrl;
int ret = this.prepareWorkingDirectory(ajob); // decompress renderer and scene archives
if (ret != 0) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
this.log.error("Client::work problem with this.prepareWorkingDirectory (ret " + ret + ")");
@@ -732,7 +732,7 @@ import okhttp3.HttpUrl;
}
catch (SheepItException e) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
if (e instanceof SheepItExceptionNoSpaceLeftOnDevice) {
@@ -754,23 +754,23 @@ import okhttp3.HttpUrl;
if (sceneFile.exists() == false) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
this.log.error("Client::work job preparation failed (scene file '" + sceneFile.getAbsolutePath()
+ "' does not exist), cleaning directory in hope to recover");
this.configuration.cleanWorkingDirectory();
this.directoryManager.cleanWorkingDirectory();
return Error.Type.MISSING_SCENE;
}
if (rendererFile.exists() == false) {
gui.setRenderingProjectName("");
for (String logline : configuration.filesystemHealthCheck()) {
for (String logline : directoryManager.filesystemHealthCheck()) {
log.debug(logline);
}
this.log.error("Client::work job preparation failed (renderer file '" + rendererFile.getAbsolutePath()
+ "' does not exist), cleaning directory in hope to recover");
this.configuration.cleanWorkingDirectory();
this.directoryManager.cleanWorkingDirectory();
return Error.Type.MISSING_RENDERER;
}