From 032dba152f6f0a9f8a39ef551ac37e2b658cb5a7 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 8 Oct 2019 20:30:47 +0200 Subject: [PATCH] fixed issue #10183: Arangoimport imports on _system when you try to create a new database (#10185) --- arangosh/Import/ImportFeature.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/arangosh/Import/ImportFeature.cpp b/arangosh/Import/ImportFeature.cpp index ed26b1418a..49e04e646d 100644 --- a/arangosh/Import/ImportFeature.cpp +++ b/arangosh/Import/ImportFeature.cpp @@ -289,8 +289,7 @@ void ImportFeature::start() { int err = TRI_ERROR_NO_ERROR; auto versionString = _httpClient->getServerVersion(&err); - auto dbName = client.databaseName(); - bool createdDatabase = false; + auto const dbName = client.databaseName(); auto successfulConnection = [&]() { std::cout << ClientFeature::buildConnectedMessage(_httpClient->getEndpointSpecification(), @@ -343,12 +342,15 @@ void ImportFeature::start() { FATAL_ERROR_EXIT(); } - successfulConnection(); - // restore old database name client.setDatabaseName(dbName); - versionString = _httpClient->getServerVersion(nullptr); - createdDatabase = true; + err = TRI_ERROR_NO_ERROR; + versionString = _httpClient->getServerVersion(&err); + + if (err != TRI_ERROR_NO_ERROR) { + // disconnecting here will abort arangoimport a few lines below + _httpClient->disconnect(); + } } if (!_httpClient->isConnected()) { @@ -359,10 +361,12 @@ void ImportFeature::start() { FATAL_ERROR_EXIT(); } + TRI_ASSERT(client.databaseName() == dbName); + // successfully connected - if (!createdDatabase) { - successfulConnection(); - } + // print out connection info + successfulConnection(); + _httpClient->disconnect(); // we do not reuse this anymore SimpleHttpClientParams params = _httpClient->params();