1
0
Fork 0

we now support umlaut temp dirs; create multi-layer temp-dirs; add tests (#9008)

* we now support umlaut temp dirs; create multi-layer temp-dirs; add tests

* Fix log
This commit is contained in:
Wilfried Goesgens 2019-05-15 21:47:05 +02:00 committed by KVS85
parent bdc2c7cdc4
commit 3c5193231f
3 changed files with 34 additions and 16 deletions

View File

@ -85,7 +85,14 @@ function arangosh (options) {
print('--------------------------------------------------------------------------------'); print('--------------------------------------------------------------------------------');
print(title); print(title);
print('--------------------------------------------------------------------------------'); print('--------------------------------------------------------------------------------');
let weirdNames = ['some dog', 'ла́ять', '犬', 'Kläffer'];
let tmpPath = fs.getTempPath();
let tmp = fs.join(tmpPath, weirdNames[0], weirdNames[1], weirdNames[2], weirdNames[3]);
process.env.TMPDIR = tmp;
process.env.TEMP = tmp;
process.env.TMP = tmp;
fs.makeDirectoryRecursive(process.env.TMPDIR);
pu.cleanupDBDirectoriesAppend(tmp);
let args = pu.makeArgs.arangosh(options); let args = pu.makeArgs.arangosh(options);
args['javascript.execute-string'] = command; args['javascript.execute-string'] = command;
args['log.level'] = 'error'; args['log.level'] = 'error';
@ -119,6 +126,11 @@ function arangosh (options) {
print(rc); print(rc);
print('expect rc: ' + expectedReturnCode); print('expect rc: ' + expectedReturnCode);
} }
// re-set the environment
process.env.TMPDIR = tmpPath;
process.env.TEMP = tmpPath;
process.env.TMP = tmpPath;
} }
runTest('testArangoshExitCodeNoConnect', runTest('testArangoshExitCodeNoConnect',

View File

@ -29,7 +29,8 @@
// server is started in unicode directory // server is started in unicode directory
const tu = require('@arangodb/test-utils'); const tu = require('@arangodb/test-utils');
const fs = require("fs"); const fs = require('fs');
const _ = require('lodash');
const functionsDocumentation = { const functionsDocumentation = {
'paths': 'paths test for server' 'paths': 'paths test for server'
@ -41,14 +42,17 @@ const testPaths = {
function paths_server(options) { function paths_server(options) {
let testCases = tu.scanTestPaths(testPaths.paths_server); let testCases = tu.scanTestPaths(testPaths.paths_server);
let weirdNames = ["some dog", "ла́ять", "犬", "Kläffer"]; let weirdNames = ['some dog', 'ла́ять', '犬', 'Kläffer'];
let tmpPath = fs.getTempPath(); let tmpPath = fs.getTempPath();
let tmp = fs.join(tmpPath, "x", weirdNames[0], weirdNames[1], weirdNames[2], weirdNames[3]); let tmp = fs.join(tmpPath, "x", weirdNames[0], weirdNames[1], weirdNames[2], weirdNames[3]);
process.env.TMPDIR = tmp; process.env.TMPDIR = tmp;
process.env.TEMP = tmp; process.env.TEMP = tmp;
process.env.TMP = tmp; process.env.TMP = tmp;
fs.makeDirectoryRecursive(process.env.TMPDIR); fs.makeDirectoryRecursive(process.env.TMPDIR);
let rc = tu.performTests(options, testCases, fs.join('server_paths', weirdNames[0], weirdNames[1], weirdNames[2], weirdNames[3]), tu.runThere); let opts = _.clone(options);
// procdump can't stand weird characters in programm options
opts.disableMonitor = true;
let rc = tu.performTests(opts, testCases, fs.join('server_paths', weirdNames[0], weirdNames[1], weirdNames[2], weirdNames[3]), tu.runThere);
process.env.TMPDIR = tmpPath; process.env.TMPDIR = tmpPath;
process.env.TEMP = tmpPath; process.env.TEMP = tmpPath;
process.env.TMP = tmpPath; process.env.TMP = tmpPath;

View File

@ -1954,19 +1954,7 @@ static std::string getTempPath() {
} }
std::string result = fromWString(tempPathName, dwReturnValue); std::string result = fromWString(tempPathName, dwReturnValue);
// ...........................................................................
// Whether or not UNICODE is defined, we assume that the temporary file name
// fits in the ascii set of characters. This is a small compromise so that
// temporary file names can be extra long if required.
// ...........................................................................
for (auto const& it : result) {
if (static_cast<uint8_t>(it) > 127) {
LOG_TOPIC("89d82", FATAL, arangodb::Logger::FIXME)
<< "Invalid characters in temporary path name: '" << result << "'";
FATAL_ERROR_ABORT();
}
}
if (result.empty() || (result.back() != TRI_DIR_SEPARATOR_CHAR)) { if (result.empty() || (result.back() != TRI_DIR_SEPARATOR_CHAR)) {
result += TRI_DIR_SEPARATOR_STR; result += TRI_DIR_SEPARATOR_STR;
} }
@ -1989,6 +1977,20 @@ static int mkDTemp(char* s, size_t bufferSize) {
tmp = fromWString(ws); tmp = fromWString(ws);
memcpy(s, tmp.data(), bufferSize); // copy back into parameter memcpy(s, tmp.data(), bufferSize); // copy back into parameter
rc = TRI_MKDIR(s, 0700); rc = TRI_MKDIR(s, 0700);
if (rc != 0) {
rc = errno;
if (rc == ENOENT) {
// for some reason we should create the upper directory too?
std::string error;
long systemError;
rc = TRI_CreateRecursiveDirectory(s, systemError, error);
if (rc != 0) {
LOG_TOPIC("6656f", ERR, arangodb::Logger::FIXME)
<< "Unable to create temporary directory " << error;
}
}
}
} }
// should error be translated to arango error code? // should error be translated to arango error code?