From c6f653822eedd1c8a8f2203c06408c312578a9c3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 4 Aug 2019 18:45:42 +0200 Subject: [PATCH 1/5] Gotta feed the file path, not the file itself --- src/yunohost/log.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index aa41cd85f..6c748f145 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -180,21 +180,20 @@ def log_display(path, number=50, share=False): # Display metadata if exist if os.path.exists(md_path): - with open(md_path, "r") as md_file: - try: - metadata = read_yaml(md_file) - except MoulinetteError as e: - error = m18n.n('log_corrupted_md_file', md_file=md_path, error=e) - if os.path.exists(log_path): - logger.warning(error) - else: - raise YunohostError(error) + try: + metadata = read_yaml(md_path) + except MoulinetteError as e: + error = m18n.n('log_corrupted_md_file', md_file=md_path, error=e) + if os.path.exists(log_path): + logger.warning(error) else: - infos['metadata_path'] = md_path - infos['metadata'] = metadata + raise YunohostError(error) + else: + infos['metadata_path'] = md_path + infos['metadata'] = metadata - if 'log_path' in metadata: - log_path = metadata['log_path'] + if 'log_path' in metadata: + log_path = metadata['log_path'] # Display logs if exist if os.path.exists(log_path): From 93691452a797818dccf8a364f3a06a87d9df97e6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 4 Aug 2019 18:46:33 +0200 Subject: [PATCH 2/5] Update changelog for 3.6.4.5 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index bf38802ab..eaa36b641 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +yunohost (3.6.4.5) stable; urgency=low + + - [fix] Typo in hotfix... + + -- Alexandre Aubin Sun, 04 Aug 2019 18:45:00 +0000 + yunohost (3.6.4.4) stable; urgency=low - [fix] Small typo breaking experimental config panel for apps (1224380) From 32e01d9cff7ab7903cff600e056720a0504c6970 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 5 Aug 2019 18:24:12 +0200 Subject: [PATCH 3/5] Don't miserably fail if we can't load detail for a log entry --- src/yunohost/log.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index 6c748f145..c322d9ef5 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -103,7 +103,12 @@ def log_list(category=[], limit=None, with_details=False): entry["started_at"] = log_datetime if with_details: - metadata = read_yaml(md_path) + try: + metadata = read_yaml(md_path) + except Exception as e: + # If we can't read the yaml for some reason, report an error and ignore this entry... + logger.error(m18n.n('log_corrupted_md_file', md_file=md_path, error=e)) + continue entry["success"] = metadata.get("success", "?") if metadata else "?" result[category].append(entry) From 9d559bf42ccce773e01fafb31f8bc94b21dc56ec Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 5 Aug 2019 18:25:25 +0200 Subject: [PATCH 4/5] We need quotes here, otheriwse yaml isn't happy later when loading the metadata file --- src/yunohost/log.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/yunohost/log.py b/src/yunohost/log.py index c322d9ef5..ef7658b01 100644 --- a/src/yunohost/log.py +++ b/src/yunohost/log.py @@ -398,7 +398,8 @@ class OperationLogger(object): dump = yaml.safe_dump(self.metadata, default_flow_style=False) for data in self.data_to_redact: - dump = dump.replace(data, "**********") + # N.B. : we need quotes here, otherwise yaml isn't happy about loading the yml later + dump = dump.replace(data, "'**********'") with open(self.md_path, 'w') as outfile: outfile.write(dump) From 6079dc9f1d58968692f0c8c69f5362f210a941fa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 5 Aug 2019 18:37:48 +0200 Subject: [PATCH 5/5] Update changelog for 3.6.4.6 --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index eaa36b641..3eb347456 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +yunohost (3.6.4.6) stable; urgency=low + + - [fix] Hopefully fix the issue about corrupted logs metadata files (d507d447, 1cec9d78) + + -- Alexandre Aubin Mon, 05 Aug 2019 18:37:00 +0000 + yunohost (3.6.4.5) stable; urgency=low - [fix] Typo in hotfix...