mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
38ce7df1a8
|
@ -1,6 +1,8 @@
|
||||||
v1.4
|
v1.4
|
||||||
------
|
------
|
||||||
|
|
||||||
|
* fixed usage of --temp-path in aranogd and arangosh
|
||||||
|
|
||||||
* issue #526: Unable to escape when an errorneous command is entered into the js shell
|
* issue #526: Unable to escape when an errorneous command is entered into the js shell
|
||||||
|
|
||||||
* issue #523: Graph and vertex methods for the javascript api
|
* issue #523: Graph and vertex methods for the javascript api
|
||||||
|
|
|
@ -256,7 +256,7 @@ void ArangoServer::buildApplicationServer () {
|
||||||
// V8 engine
|
// V8 engine
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
_applicationV8 = new ApplicationV8(_binaryPath, _tempPath);
|
_applicationV8 = new ApplicationV8(_binaryPath);
|
||||||
_applicationServer->addFeature(_applicationV8);
|
_applicationServer->addFeature(_applicationV8);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
@ -411,9 +411,15 @@ void ArangoServer::buildApplicationServer () {
|
||||||
CLEANUP_LOGGING_AND_EXIT_ON_FATAL_ERROR();
|
CLEANUP_LOGGING_AND_EXIT_ON_FATAL_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the temp-path
|
||||||
|
if (_applicationServer->programOptions().has("temp-path")) {
|
||||||
|
TRI_SetUserTempPath((char*) _tempPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// dump version details
|
// dump version details
|
||||||
LOGGER_INFO(rest::Version::getVerboseVersionString());
|
LOGGER_INFO(rest::Version::getVerboseVersionString());
|
||||||
|
|
||||||
|
// configure v8
|
||||||
if (_applicationServer->programOptions().has("development-mode")) {
|
if (_applicationServer->programOptions().has("development-mode")) {
|
||||||
_developmentMode = true;
|
_developmentMode = true;
|
||||||
_applicationV8->enableDevelopmentMode();
|
_applicationV8->enableDevelopmentMode();
|
||||||
|
|
|
@ -174,9 +174,8 @@ void ApplicationV8::V8Context::handleGlobalContextMethods () {
|
||||||
/// @brief constructor
|
/// @brief constructor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ApplicationV8::ApplicationV8 (string const& binaryPath, string const& tempPath)
|
ApplicationV8::ApplicationV8 (string const& binaryPath)
|
||||||
: ApplicationFeature("V8"),
|
: ApplicationFeature("V8"),
|
||||||
_tempPath(tempPath),
|
|
||||||
_startupPath(),
|
_startupPath(),
|
||||||
_modulesPath(),
|
_modulesPath(),
|
||||||
_packagePath(),
|
_packagePath(),
|
||||||
|
@ -739,7 +738,7 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
|
||||||
|
|
||||||
TRI_InitV8Buffer(context->_context);
|
TRI_InitV8Buffer(context->_context);
|
||||||
TRI_InitV8Conversions(context->_context);
|
TRI_InitV8Conversions(context->_context);
|
||||||
TRI_InitV8Utils(context->_context, _modulesPath, _packagePath, _tempPath);
|
TRI_InitV8Utils(context->_context, _modulesPath, _packagePath);
|
||||||
TRI_InitV8Shell(context->_context);
|
TRI_InitV8Shell(context->_context);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -173,7 +173,7 @@ namespace triagens {
|
||||||
/// @brief constructor
|
/// @brief constructor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ApplicationV8 (string const&, string const&);
|
ApplicationV8 (string const&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief destructor
|
/// @brief destructor
|
||||||
|
@ -345,12 +345,6 @@ namespace triagens {
|
||||||
/// @{
|
/// @{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief temporary path
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
string _tempPath;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief path to the directory containing alternate startup scripts
|
/// @brief path to the directory containing alternate startup scripts
|
||||||
///
|
///
|
||||||
|
|
|
@ -2224,8 +2224,11 @@ void TRI_ReleaseCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* co
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TRI_InitialiseVocBase () {
|
void TRI_InitialiseVocBase () {
|
||||||
|
// TODO: these two fcalls can probably be removed because we're initialising
|
||||||
|
// BasicsC anyway
|
||||||
TRI_InitialiseHashes();
|
TRI_InitialiseHashes();
|
||||||
TRI_InitialiseRandom();
|
TRI_InitialiseRandom();
|
||||||
|
|
||||||
TRI_GlobalInitStatementListAql();
|
TRI_GlobalInitStatementListAql();
|
||||||
|
|
||||||
ServerIdentifier = TRI_UInt16Random();
|
ServerIdentifier = TRI_UInt16Random();
|
||||||
|
|
|
@ -341,6 +341,11 @@ void ArangoClient::parse (ProgramOptions& options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set temp path
|
||||||
|
if (options.has("temp-path")) {
|
||||||
|
TRI_SetUserTempPath((char*) _tempPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// check if have a password
|
// check if have a password
|
||||||
_hasPassword = options.has("server.password") ||
|
_hasPassword = options.has("server.password") ||
|
||||||
options.has("server.disable-authentication") ||
|
options.has("server.disable-authentication") ||
|
||||||
|
@ -668,14 +673,6 @@ void ArangoClient::setUsePager (bool value) {
|
||||||
_usePager = value;
|
_usePager = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief gets the temporary path
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
string const& ArangoClient::tempPath () const {
|
|
||||||
return _tempPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief gets endpoint to connect to as string
|
/// @brief gets endpoint to connect to as string
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -325,12 +325,6 @@ namespace triagens {
|
||||||
|
|
||||||
void setUsePager (bool);
|
void setUsePager (bool);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief gets the temporary path
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
string const& tempPath () const;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief gets endpoint to connect to as string
|
/// @brief gets endpoint to connect to as string
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1454,7 +1454,8 @@ int main (int argc, char* argv[]) {
|
||||||
TRI_AddGlobalVariableVocbase(context, "SYS_OUTPUT", v8::FunctionTemplate::New(JS_PagerOutput)->GetFunction());
|
TRI_AddGlobalVariableVocbase(context, "SYS_OUTPUT", v8::FunctionTemplate::New(JS_PagerOutput)->GetFunction());
|
||||||
|
|
||||||
TRI_InitV8Buffer(context);
|
TRI_InitV8Buffer(context);
|
||||||
TRI_InitV8Utils(context, StartupModules, StartupPackages, BaseClient.tempPath());
|
|
||||||
|
TRI_InitV8Utils(context, StartupModules, StartupPackages);
|
||||||
TRI_InitV8Shell(context);
|
TRI_InitV8Shell(context);
|
||||||
|
|
||||||
// reset the prompt error flag (will determine prompt colors)
|
// reset the prompt error flag (will determine prompt colors)
|
||||||
|
|
|
@ -67,6 +67,12 @@
|
||||||
|
|
||||||
static bool Initialised = false;
|
static bool Initialised = false;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief user-defined temporary path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static char* TempPath;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief names of blocking files
|
/// @brief names of blocking files
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1746,7 +1752,8 @@ int TRI_GetTempName (char const* directory,
|
||||||
char* temp;
|
char* temp;
|
||||||
int tries;
|
int tries;
|
||||||
|
|
||||||
temp = TRI_GetTempPath();
|
temp = TRI_GetUserTempPath();
|
||||||
|
|
||||||
if (directory != NULL) {
|
if (directory != NULL) {
|
||||||
dir = TRI_Concatenate2File(temp, directory);
|
dir = TRI_Concatenate2File(temp, directory);
|
||||||
}
|
}
|
||||||
|
@ -1816,6 +1823,58 @@ int TRI_GetTempName (char const* directory,
|
||||||
return TRI_ERROR_INTERNAL;
|
return TRI_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief return the user-defined temp path, with a fallback to the system's
|
||||||
|
/// temp path if none is specified
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
char* TRI_GetUserTempPath (void) {
|
||||||
|
if (TempPath == NULL) {
|
||||||
|
return TRI_GetTempPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRI_DuplicateString(TempPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief set a new user-defined temp path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_SetUserTempPath (char* path) {
|
||||||
|
if (TempPath != NULL) {
|
||||||
|
TRI_FreeString(TRI_CORE_MEM_ZONE, TempPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
// unregister user-defined temp path
|
||||||
|
TempPath = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// copy the user-defined temp path
|
||||||
|
TempPath = TRI_DuplicateString(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief initialise the files subsystem
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_InitialiseFiles (void) {
|
||||||
|
// clear user-defined temp path
|
||||||
|
TempPath = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief shutdown the files subsystem
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_ShutdownFiles (void) {
|
||||||
|
if (TempPath != NULL) {
|
||||||
|
// free any user-defined temp-path
|
||||||
|
TRI_FreeString(TRI_CORE_MEM_ZONE, TempPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -270,6 +270,31 @@ char* TRI_GetTempPath (void);
|
||||||
|
|
||||||
int TRI_GetTempName (char const*, char**, const bool);
|
int TRI_GetTempName (char const*, char**, const bool);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief return the user-defined temp path, with a fallback to the system's
|
||||||
|
/// temp path if none is specified
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
char* TRI_GetUserTempPath (void);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief set a new user-defined temp path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_SetUserTempPath (char*);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief initialise the files subsystem
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_InitialiseFiles (void);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief shutdown the files subsystem
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TRI_ShutdownFiles (void);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
|
#include "BasicsC/files.h"
|
||||||
#include "BasicsC/hashes.h"
|
#include "BasicsC/hashes.h"
|
||||||
#include "BasicsC/logging.h"
|
#include "BasicsC/logging.h"
|
||||||
#include "BasicsC/mersenne.h"
|
#include "BasicsC/mersenne.h"
|
||||||
|
@ -53,6 +54,7 @@ void TRI_InitialiseC (int argc, char* argv[]) {
|
||||||
TRI_InitialiseMemory();
|
TRI_InitialiseMemory();
|
||||||
TRI_InitialiseMersenneTwister();
|
TRI_InitialiseMersenneTwister();
|
||||||
TRI_InitialiseError();
|
TRI_InitialiseError();
|
||||||
|
TRI_InitialiseFiles();
|
||||||
TRI_InitialiseMimetypes();
|
TRI_InitialiseMimetypes();
|
||||||
TRI_InitialiseLogging(false);
|
TRI_InitialiseLogging(false);
|
||||||
TRI_InitialiseHashes();
|
TRI_InitialiseHashes();
|
||||||
|
@ -74,6 +76,7 @@ void TRI_ShutdownC () {
|
||||||
TRI_ShutdownHashes();
|
TRI_ShutdownHashes();
|
||||||
TRI_ShutdownLogging();
|
TRI_ShutdownLogging();
|
||||||
TRI_ShutdownMimetypes();
|
TRI_ShutdownMimetypes();
|
||||||
|
TRI_ShutdownFiles();
|
||||||
TRI_ShutdownError();
|
TRI_ShutdownError();
|
||||||
TRI_ShutdownMemory();
|
TRI_ShutdownMemory();
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,7 +698,7 @@ static v8::Handle<v8::Value> JS_GetTempPath (v8::Arguments const& argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return result
|
// return result
|
||||||
return scope.Close(v8::String::New(TempPath.c_str(), TempPath.size()));
|
return scope.Close(v8::String::New(TRI_GetUserTempPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1693,16 +1693,24 @@ static v8::Handle<v8::Value> JS_RemoveRecursiveDirectory (v8::Arguments const& a
|
||||||
TRI_V8_EXCEPTION_PARAMETER(scope, "<path> must be a valid directory name");
|
TRI_V8_EXCEPTION_PARAMETER(scope, "<path> must be a valid directory name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TempPath.size() < 8) {
|
char* tempPath = TRI_GetUserTempPath();
|
||||||
|
|
||||||
|
if (tempPath == NULL || strlen(tempPath) < 6) {
|
||||||
// some security measure so we don't accidently delete all our files
|
// some security measure so we don't accidently delete all our files
|
||||||
|
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
|
||||||
|
|
||||||
TRI_V8_EXCEPTION_PARAMETER(scope, "temporary directory name is too short. will not remove directory");
|
TRI_V8_EXCEPTION_PARAMETER(scope, "temporary directory name is too short. will not remove directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
const string path(*name);
|
const string path(*name);
|
||||||
if (path.substr(0, TempPath.size()) != TempPath) {
|
if (! TRI_EqualString2(path.c_str(), tempPath, strlen(tempPath))) {
|
||||||
|
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
|
||||||
|
|
||||||
TRI_V8_EXCEPTION_PARAMETER(scope, "directory to be removed is outside of temporary path");
|
TRI_V8_EXCEPTION_PARAMETER(scope, "directory to be removed is outside of temporary path");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
|
||||||
|
|
||||||
int res = TRI_RemoveDirectory(*name);
|
int res = TRI_RemoveDirectory(*name);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
|
@ -2389,8 +2397,7 @@ v8::Handle<v8::Array> TRI_V8PathList (string const& modules) {
|
||||||
|
|
||||||
void TRI_InitV8Utils (v8::Handle<v8::Context> context,
|
void TRI_InitV8Utils (v8::Handle<v8::Context> context,
|
||||||
string const& modules,
|
string const& modules,
|
||||||
string const& packages,
|
string const& packages) {
|
||||||
string const& tempPath) {
|
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
|
||||||
// check the isolate
|
// check the isolate
|
||||||
|
@ -2400,8 +2407,6 @@ void TRI_InitV8Utils (v8::Handle<v8::Context> context,
|
||||||
v8::Handle<v8::FunctionTemplate> ft;
|
v8::Handle<v8::FunctionTemplate> ft;
|
||||||
v8::Handle<v8::ObjectTemplate> rt;
|
v8::Handle<v8::ObjectTemplate> rt;
|
||||||
|
|
||||||
TempPath = tempPath;
|
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// generate the general error template
|
// generate the general error template
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
|
@ -65,12 +65,6 @@ class TRI_Utf8ValueNFC {
|
||||||
// --SECTION-- public constants
|
// --SECTION-- public constants
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief temporary path
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static std::string TempPath;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief slot for a type
|
/// @brief slot for a type
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -201,8 +195,7 @@ v8::Handle<v8::Array> TRI_V8PathList (std::string const& modules);
|
||||||
|
|
||||||
void TRI_InitV8Utils (v8::Handle<v8::Context>,
|
void TRI_InitV8Utils (v8::Handle<v8::Context>,
|
||||||
std::string const& modules,
|
std::string const& modules,
|
||||||
std::string const& nodes,
|
std::string const& nodes);
|
||||||
std::string const& tempPath);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue