mirror of https://gitee.com/bigwinds/arangodb
parent
c50d346453
commit
4bbd6a02bb
|
@ -119,6 +119,12 @@ void AqlFunctionFeature::toVelocyPack(VPackBuilder& builder) {
|
|||
builder.close();
|
||||
}
|
||||
|
||||
bool AqlFunctionFeature::exists(std::string const& name) const {
|
||||
auto it = _functionNames.find(name);
|
||||
|
||||
return it != _functionNames.end();
|
||||
}
|
||||
|
||||
Function const* AqlFunctionFeature::byName(std::string const& name) {
|
||||
auto it = _functionNames.find(name);
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ class AqlFunctionFeature final : public application_features::ApplicationFeature
|
|||
void toVelocyPack(arangodb::velocypack::Builder&);
|
||||
Function const* byName(std::string const& name);
|
||||
|
||||
bool exists(std::string const& name) const;
|
||||
|
||||
private:
|
||||
// Internal functions
|
||||
void addTypeCheckFunctions();
|
||||
|
|
|
@ -90,17 +90,19 @@ void ServerState::findHost(std::string const& fallback) {
|
|||
|
||||
// Now look at the contents of the file /etc/machine-id, if it exists:
|
||||
std::string name = "/etc/machine-id";
|
||||
try {
|
||||
_host = arangodb::basics::FileUtils::slurp(name);
|
||||
while (!_host.empty() &&
|
||||
(_host.back() == '\r' || _host.back() == '\n' ||
|
||||
_host.back() == ' ')) {
|
||||
_host.erase(_host.size() - 1);
|
||||
}
|
||||
if (!_host.empty()) {
|
||||
return;
|
||||
}
|
||||
} catch (...) { }
|
||||
if (arangodb::basics::FileUtils::exists(name)) {
|
||||
try {
|
||||
_host = arangodb::basics::FileUtils::slurp(name);
|
||||
while (!_host.empty() &&
|
||||
(_host.back() == '\r' || _host.back() == '\n' ||
|
||||
_host.back() == ' ')) {
|
||||
_host.erase(_host.size() - 1);
|
||||
}
|
||||
if (!_host.empty()) {
|
||||
return;
|
||||
}
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
static_assert(sizeof(uuid_t) == 16, "");
|
||||
|
|
|
@ -35,7 +35,7 @@ bool addFunction(
|
|||
) {
|
||||
// check that a function by the given name is not registred to avoid
|
||||
// triggering an assert inside AqlFunctionFeature::add(...)
|
||||
if (getFunction(functions, function.name)) {
|
||||
if (functions.exists(function.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue