From 9e1dac99f723132a6c2fd652be726db093014ea8 Mon Sep 17 00:00:00 2001 From: ljf Date: Tue, 5 Jun 2018 17:38:46 +0200 Subject: [PATCH] [fix] Avoid double log if name change --- src/yunohost/log.py | 7 ++++++- src/yunohost/service.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index bcfb93dfb..859e4b43a 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -278,6 +278,7 @@ class UnitOperation(object): self.started_at = None self.ended_at = None self.logger = None + self._name = None self.path = OPERATIONS_PATH @@ -324,6 +325,9 @@ class UnitOperation(object): Name of the operation This name is used as filename, so don't use space """ + if self._name is not None: + return self._name + name = [self.started_at.strftime("%Y%m%d-%H%M%S")] name += [self.operation] if self.related_to: @@ -331,7 +335,8 @@ class UnitOperation(object): name += [self.related_to[0][1]] else: name += self.related_to[0].values() - return '-'.join(name) + self._name = '-'.join(name) + return self._name @property def metadata(self): diff --git a/src/yunohost/service.py b/src/yunohost/service.py index d90965d3e..6306f0b8a 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -290,8 +290,6 @@ def service_regen_conf(uo, names=[], with_diff=False, force=False, dry_run=False """ result = {} - if not dry_run: - uo.start() # Return the list of pending conf if list_pending: pending_conf = _get_pending_conf(names) @@ -305,6 +303,12 @@ def service_regen_conf(uo, names=[], with_diff=False, force=False, dry_run=False } return pending_conf + if not dry_run: + uo.related_to = [('service', x) for x in names] + if not names: + uo.related_to = [('service', 'all')] + uo.start() + # Clean pending conf directory if os.path.isdir(PENDING_CONF_DIR): if not names: @@ -340,8 +344,13 @@ def service_regen_conf(uo, names=[], with_diff=False, force=False, dry_run=False # Set the processing method _regen = _process_regen_conf if not dry_run else lambda *a, **k: True + uo.related_to = [] + # Iterate over services and process pending conf for service, conf_files in _get_pending_conf(names).items(): + if not dry_run: + uo.related_to.append(('service', service)) + logger.info(m18n.n( 'service_regenconf_pending_applying' if not dry_run else 'service_regenconf_dry_pending_applying',