Update PR

* Update PR
This commit is contained in:
abraunegg 2023-09-09 07:36:24 +10:00
parent 34cb3031e8
commit 4756680ccf
2 changed files with 29 additions and 16 deletions

View file

@ -65,10 +65,9 @@ class CurlEngine {
// Ensure that we ARE NOT reusing TCP sockets connections - setting to 0 ensures that we ARE reusing connections (we did this in v2.4.xx) to ensure connections remained open and usable // Ensure that we ARE NOT reusing TCP sockets connections - setting to 0 ensures that we ARE reusing connections (we did this in v2.4.xx) to ensure connections remained open and usable
// Setting this to 1 ensures that when we close the curl instance, any open sockets are closed - which we need to do when running // Setting this to 1 ensures that when we close the curl instance, any open sockets are closed - which we need to do when running
// multiple threads and API instances at the same time otherwise we run out of local files | sockets pretty quickly // multiple threads and API instances at the same time otherwise we run out of local files | sockets pretty quickly
// The libcurl default is 1 - ensure we are configuring not to reuse connections // The libcurl default is 1 - ensure we are configuring not to reuse connections and leave unused sockets open
http.handle.set(CurlOption.forbid_reuse,1); http.handle.set(CurlOption.forbid_reuse,1);
if (httpsDebug) { if (httpsDebug) {
// Output what options we are using so that in the debug log this can be tracked // Output what options we are using so that in the debug log this can be tracked
log.vdebug("http.dnsTimeout = ", dnsTimeout); log.vdebug("http.dnsTimeout = ", dnsTimeout);

View file

@ -155,7 +155,7 @@ int main(string[] cliArgs) {
// Set runtimeDatabaseFile, this will get updated if we are using --dry-run // Set runtimeDatabaseFile, this will get updated if we are using --dry-run
runtimeDatabaseFile = appConfig.databaseFilePath; runtimeDatabaseFile = appConfig.databaseFilePath;
// Expand any ~ in the configuration for our operational environment // Expand any ~ in the configuration for our operational environment. Read in 'sync_dir' from appConfig
runtimeSyncDirectory = updateTildeConfigDirectives(appConfig.getValueString("sync_dir")); runtimeSyncDirectory = updateTildeConfigDirectives(appConfig.getValueString("sync_dir"));
// DEVELOPER OPTIONS OUTPUT // DEVELOPER OPTIONS OUTPUT
@ -800,32 +800,46 @@ void displaySyncOutcome() {
} }
} }
string updateTildeConfigDirectives(string configValue) { string updateTildeConfigDirectives(string inputValue) {
string outputValue;
log.vdebug("sync_dir: Setting runtimeSyncDirectory from config value 'sync_dir'");
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){ if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
log.vdebug("sync_dir: No SHELL or USER environment variable configuration detected"); log.vdebug("sync_dir: No SHELL or USER environment variable configuration detected");
// No shell or user set, so expandTilde() will fail - usually headless system running under init.d / systemd or potentially Docker // No shell or user set, so expandTilde() will fail - usually headless system running under init.d / systemd or potentially Docker
// Does the 'currently configured' sync_dir include a ~ // Does the 'currently configured' sync_dir include a ~
if (canFind(appConfig.getValueString("sync_dir"), "~")) { if (canFind(inputValue, "~")) {
// A ~ was found in sync_dir // A ~ was found in sync_dir
log.vdebug("sync_dir: A '~' was found in sync_dir, using the calculated 'homePath' to replace '~' as no SHELL or USER environment variable set"); log.vdebug("sync_dir: A '~' was found in 'sync_dir', using the calculated 'homePath' to replace '~' as no SHELL or USER environment variable set");
configValue = appConfig.defaultHomePath ~ strip(appConfig.getValueString("sync_dir"), "~"); outputValue = appConfig.defaultHomePath ~ strip(inputValue, "~");
} else { } else {
// No ~ found in sync_dir, use as is // No ~ found in sync_dir, use as is
log.vdebug("sync_dir: Getting runtimeSyncDirectory from config value sync_dir"); log.vdebug("sync_dir: Using configured 'sync_dir' path as-is as no SHELL or USER environment variable configuration detected");
configValue = appConfig.getValueString("sync_dir"); outputValue = inputValue;
} }
} else { } else {
// A shell and user is set, expand any ~ as this will be expanded correctly if present // A shell and user environment variable is set, expand any ~ as this will be expanded correctly if present
log.vdebug("sync_dir: Getting runtimeSyncDirectory from config value sync_dir"); if (canFind(inputValue, "~")) {
if (canFind(appConfig.getValueString("sync_dir"), "~")) { log.vdebug("sync_dir: A '~' was found in configured 'sync_dir', automatically expanding as SHELL and USER environment variable is set");
log.vdebug("sync_dir: A '~' was found in configured sync_dir, automatically expanding as SHELL and USER environment variable is set"); outputValue = expandTilde(inputValue);
configValue = expandTilde(appConfig.getValueString("sync_dir"));
} else { } else {
configValue = appConfig.getValueString("sync_dir"); // No ~ found in sync_dir, does the path begin with a '/' ?
log.vdebug("sync_dir: Using configured 'sync_dir' path as-is as however SHELL or USER environment variable configuration detected - should be placed in USER home directory");
if (!startsWith(inputValue, "/")) {
log.log("Configured 'sync_dir' does not start with a '/' or '~/' - adjusting configured 'sync_dir' to use User Home Directory as base for 'sync_dir' path");
string updatedPathWithHome = "~/" ~ inputValue;
outputValue = expandTilde(updatedPathWithHome);
} else {
log.vdebug("use 'sync_dir' as is - no touch");
outputValue = inputValue;
}
} }
} }
return configValue; // What will runtimeSyncDirectory be actually set to?
log.vdebug("runtimeSyncDirectory set to: ", outputValue);
return outputValue;
} }
void processResyncDatabaseRemoval(string databaseFilePathToRemove) { void processResyncDatabaseRemoval(string databaseFilePathToRemove) {