From d78f7fa29e1f61db23ff8a66d9da19407a065298 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 28 Sep 2018 13:20:35 +0200 Subject: [PATCH] fix compilation --- arangod/V8Server/V8DealerFeature.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arangod/V8Server/V8DealerFeature.cpp b/arangod/V8Server/V8DealerFeature.cpp index 67a79132ee..fc9671bffe 100644 --- a/arangod/V8Server/V8DealerFeature.cpp +++ b/arangod/V8Server/V8DealerFeature.cpp @@ -22,6 +22,7 @@ #include "V8DealerFeature.h" +#include #include #include "3rdParty/valgrind/valgrind.h" @@ -41,6 +42,7 @@ #include "Random/RandomGenerator.h" #include "RestServer/DatabaseFeature.h" #include "RestServer/DatabasePathFeature.h" +#include "Rest/Version.h" #include "Scheduler/JobGuard.h" #include "Scheduler/SchedulerFeature.h" #include "Transaction/V8Context.h" @@ -194,6 +196,27 @@ void V8DealerFeature::validateOptions(std::shared_ptr options) { ctx->normalizePath(_startupDirectory, "javascript.startup-directory", true); ctx->normalizePath(_moduleDirectory, "javascript.module-directory", false); + // try to append the current version name to the startup directory, + // so instead of "/path/to/js" we will get "/path/to/js/3.4.0" + std::string const versionAppendix = std::regex_replace(rest::Version::getServerVersion(), std::regex("-.*$"), ""); + std::string versionedPath = basics::FileUtils::buildFilename(_startupDirectory, versionAppendix); + + LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific startup-directory '" << versionedPath << "'"; + if (basics::FileUtils::isDirectory(versionedPath)) { + // version-specific js path exists! + _startupDirectory = versionedPath; + } + + for (auto& it : _moduleDirectory) { + versionedPath = basics::FileUtils::buildFilename(it, versionAppendix); + + LOG_TOPIC(DEBUG, Logger::V8) << "checking for existence of version-specific module-directory '" << versionedPath << "'"; + if (basics::FileUtils::isDirectory(versionedPath)) { + // version-specific js path exists! + it = versionedPath; + } + } + // check whether app-path was specified if (_appPath.empty()) { LOG_TOPIC(FATAL, arangodb::Logger::V8) << "no value has been specified for --javascript.app-path";