Try to hardlink shared archives before copying
This will reduce both the disk usage and IO load on systems with multiple clients.
This commit is contained in:
@@ -25,6 +25,7 @@ import java.io.IOException;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -950,12 +951,7 @@ import okhttp3.HttpUrl;
|
|||||||
if (!new File(renderer_archive).exists()) {
|
if (!new File(renderer_archive).exists()) {
|
||||||
this.gui.status("Copying renderer from shared downloads directory");
|
this.gui.status("Copying renderer from shared downloads directory");
|
||||||
|
|
||||||
try {
|
copySharedArchive(bestRendererArchive, renderer_archive);
|
||||||
Files.copy(Paths.get(bestRendererArchive), Paths.get(renderer_archive), StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
this.gui.error("Error while copying renderer from shared downloads directory to working dir");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!renderer_path_file.exists()) {
|
if (!renderer_path_file.exists()) {
|
||||||
@@ -989,13 +985,7 @@ import okhttp3.HttpUrl;
|
|||||||
|
|
||||||
if (!new File(scene_archive).exists()) {
|
if (!new File(scene_archive).exists()) {
|
||||||
this.gui.status("Copying scene from common directory");
|
this.gui.status("Copying scene from common directory");
|
||||||
|
copySharedArchive(bestSceneArchive, scene_archive);
|
||||||
try {
|
|
||||||
Files.copy(Paths.get(bestSceneArchive), Paths.get(scene_archive), StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
this.gui.error("Error while copying scene from common directory to working dir");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scene_path_file.exists()) {
|
if (!scene_path_file.exists()) {
|
||||||
@@ -1018,6 +1008,25 @@ import okhttp3.HttpUrl;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copySharedArchive(String existingArchive, String targetArchive) {
|
||||||
|
Path existingArchivePath = Paths.get(existingArchive);
|
||||||
|
Path targetArchivePath = Paths.get(targetArchive);
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
Files.createLink(targetArchivePath, existingArchivePath);
|
||||||
|
log.debug("Created hardlink from " + targetArchivePath + " to " + existingArchivePath);
|
||||||
|
}
|
||||||
|
catch (UnsupportedOperationException x) {
|
||||||
|
// Creating hardlinks might not be supported on some filesystems
|
||||||
|
log.debug("Failed to create hardlink, falling back to copying file to " + targetArchivePath);
|
||||||
|
Files.copy(existingArchivePath, targetArchivePath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
this.gui.error("Error while copying " + existingArchive + " from shared downloads directory to working dir");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Error.Type confirmJob(Job ajob, int checkpoint) {
|
protected Error.Type confirmJob(Job ajob, int checkpoint) {
|
||||||
String url_real = String.format(LOCALE, "%s&rendertime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getDuration(),
|
String url_real = String.format(LOCALE, "%s&rendertime=%d&memoryused=%s", ajob.getValidationUrl(), ajob.getProcessRender().getDuration(),
|
||||||
ajob.getProcessRender().getPeakMemoryUsed());
|
ajob.getProcessRender().getPeakMemoryUsed());
|
||||||
|
|||||||
Reference in New Issue
Block a user