mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-20 03:36:25 +00:00
create directories on save
This commit is contained in:
parent
ca5a64236d
commit
706d3085da
@ -66,13 +66,18 @@ def write_config(tahoe_cfg, config):
|
|||||||
"""
|
"""
|
||||||
Write a configuration to a file.
|
Write a configuration to a file.
|
||||||
|
|
||||||
:param FilePath tahoe_cfg: The path to which to write the config.
|
:param FilePath tahoe_cfg: The path to which to write the
|
||||||
|
config. The directories are created if they do not already exist.
|
||||||
|
|
||||||
:param ConfigParser config: The configuration to write.
|
:param ConfigParser config: The configuration to write.
|
||||||
|
|
||||||
:return: ``None``
|
:return: ``None``
|
||||||
"""
|
"""
|
||||||
tmp = tahoe_cfg.temporarySibling()
|
tmp = tahoe_cfg.temporarySibling()
|
||||||
|
try:
|
||||||
|
tahoe_cfg.parent().makedirs()
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
# FilePath.open can only open files in binary mode which does not work
|
# FilePath.open can only open files in binary mode which does not work
|
||||||
# with ConfigParser.write.
|
# with ConfigParser.write.
|
||||||
with open(tmp.path, "wt") as fp:
|
with open(tmp.path, "wt") as fp:
|
||||||
|
Loading…
Reference in New Issue
Block a user