mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-11 05:31:26 +00:00
save only fails sometimes
This commit is contained in:
parent
72f2e25f86
commit
1e1aad8cc8
@ -144,7 +144,7 @@ def remove(ctx, name):
|
||||
fp.child('{}.cert.{}'.format(name, cert_count)).remove()
|
||||
cert_count += 1
|
||||
|
||||
save_grid_manager(fp, ctx.obj.grid_manager)
|
||||
save_grid_manager(fp, ctx.obj.grid_manager, create=False)
|
||||
|
||||
|
||||
@grid_manager.command()
|
||||
@ -177,10 +177,10 @@ def sign(ctx, name, expiry_days):
|
||||
sign a new certificate
|
||||
"""
|
||||
fp = _config_path_from_option(ctx.parent.params["config"])
|
||||
expiry_seconds = int(expiry_days) * 86400
|
||||
expiry = timedelta(days=expiry_days)
|
||||
|
||||
try:
|
||||
certificate = ctx.obj.grid_manager.sign(name, expiry_seconds)
|
||||
certificate = ctx.obj.grid_manager.sign(name, expiry)
|
||||
except KeyError:
|
||||
raise click.ClickException(
|
||||
"No storage-server called '{}' exists".format(name)
|
||||
|
@ -252,7 +252,7 @@ class _GridManager(object):
|
||||
return data
|
||||
|
||||
|
||||
def save_grid_manager(file_path, grid_manager):
|
||||
def save_grid_manager(file_path, grid_manager, create=True):
|
||||
"""
|
||||
Writes a Grid Manager configuration.
|
||||
|
||||
@ -260,6 +260,9 @@ def save_grid_manager(file_path, grid_manager):
|
||||
(if None, stdout is used)
|
||||
|
||||
:param grid_manager: a _GridManager instance
|
||||
|
||||
:param bool create: if True (the default) we are creating a new
|
||||
grid-manager and will fail if the directory already exists.
|
||||
"""
|
||||
data = json.dumps(
|
||||
grid_manager.marshal(),
|
||||
@ -269,8 +272,12 @@ def save_grid_manager(file_path, grid_manager):
|
||||
if file_path is None:
|
||||
print("{}\n".format(data))
|
||||
else:
|
||||
file_path.makedirs()
|
||||
file_path.chmod(0o700)
|
||||
try:
|
||||
file_path.makedirs()
|
||||
file_path.chmod(0o700)
|
||||
except OSError:
|
||||
if create:
|
||||
raise
|
||||
with file_path.child("config.json").open("w") as f:
|
||||
f.write("{}\n".format(data))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user