Skip to content
Snippets Groups Projects
Commit 38a70e41 authored by Alexander Turenko's avatar Alexander Turenko Committed by Alexander Turenko
Browse files

config: create parent directories in mkdir applier

Before this patch an attempt to set, say, `wal.dir` option to a
non-existent directory `foo` succeeds, while the same with `foo/bar`
directory fails.

The patch removes a race condition check, because `fio.mktree()`
performs the check on its own. See #4660 for details.

Part of #8862

NO_DOC=It is a bugfix.
parent 07e6060b
No related branches found
No related tags found
No related merge requests found
## bugfix/config
* Support parent directories creation for options that accept a directory or a
file (gh-8862).
......@@ -7,21 +7,10 @@ local function safe_mkdir(prefix, dir)
if stat == nil then
log.verbose('%s: create directory: %s', prefix, dir)
local _, err = fio.mkdir(dir)
-- A file can be created by another process in between the
-- stat() and the mkdir() calls.
--
-- In this case mkdir() gives an error. Let's ignore it if
-- the created file is a directory, but raise the error
-- otherwise.
local _, err = fio.mktree(dir)
if err ~= nil then
if fio.path.is_dir(dir) then
log.verbose('%s: the directory already exists: %s', prefix, dir)
else
error(('%s: failed to create directory %s: %s'):format(prefix,
dir, err))
end
error(('%s: failed to create directory %s: %s'):format(prefix,
dir, err))
end
else
if fio.path.is_dir(dir) then
......
local t = require('luatest')
local helpers = require('test.config-luatest.helpers')
local g = helpers.group()
g.test_nested_dirs = function(g)
local verify = function()
local fio = require('fio')
for _, dir in ipairs({'a/b', 'd/e/f', 'g/h/i', 'j/k/l'}) do
t.assert_equals(fio.path.is_dir(dir), true)
end
end
helpers.success_case(g, {
options = {
['process.pid_file'] = 'a/b/c.pid',
['vinyl.dir'] = 'd/e/f',
['wal.dir'] = 'g/h/i',
['snapshot.dir'] = 'j/k/l',
},
verify = verify,
})
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment