Feature: support for shared downloads directory (#295)

* Feature: support for shared downloads directory

This feature is especially relevant for users with several clients running simultaneously within the same computer (computers running several GPUs or any combination of GPUs + CPUs) or multiple computers running in a network. The feature allows the user to specify a shared downloads directory via the new -shared-downloads-dir client option. All the clients using that option will share the same binaries and scene files.

How it works?
The first client downloading a binary or scene will save the file in the directory especified in -shared-downloads-directory. The rest of the clients using the same option will wait until the file has been downloaded. Once the file has been downloaded, it will be ready for the rest of the clients.

This feature is especially relevant for users with metered/slow connections or multiple computers/clients that don't want to download the same binary/file multiple times.

IMPORTANT: All the clients intended to share the binaries and scenes must execute the client with the same -shared-downloads-dir parameter.
This commit is contained in:
Luis Uguina
2020-10-21 22:03:09 +11:00
committed by GitHub
parent 70d7dc052c
commit 6587b4dcef
5 changed files with 157 additions and 14 deletions

View File

@@ -43,6 +43,7 @@ import lombok.Data;
private String configFilePath;
private File workingDirectory;
private File sharedDownloadsDirectory;
private File storageDirectory; // for permanent storage (binary archive)
private boolean userHasSpecifiedACacheDir;
private String static_exeDirName;
@@ -87,6 +88,7 @@ import lombok.Data;
this.userHasSpecifiedACacheDir = false;
this.detectGPUs = true;
this.workingDirectory = null;
this.sharedDownloadsDirectory = null;
this.storageDirectory = null;
this.setCacheDir(cache_dir_);
this.printLog = false;
@@ -147,6 +149,13 @@ import lombok.Data;
this.storageDirectory.mkdirs();
}
if (this.sharedDownloadsDirectory != null) {
this.sharedDownloadsDirectory.mkdirs();
if (!this.sharedDownloadsDirectory.exists()) {
System.err.println("Configuration::setCacheDir Unable to create common directory " + this.sharedDownloadsDirectory.getAbsolutePath());
}
}
}
public void setStorageDir(File dir) {
@@ -253,6 +262,12 @@ import lombok.Data;
files.addAll(Arrays.asList(filesInDirectory));
}
}
if (this.sharedDownloadsDirectory != null) {
File[] filesInDirectory = this.sharedDownloadsDirectory.listFiles();
if (filesInDirectory != null) {
files.addAll(Arrays.asList(filesInDirectory));
}
}
for (File file : files) {
if (file.isFile()) {