From d77c616d71eb7a48f6e613b49129f8494830dfb7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 20 May 2018 21:09:18 +0200 Subject: [PATCH] Return None directly if we try to calculate the hash of a file that does not exists --- src/yunohost/service.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index d02adc083..866fab414 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -713,6 +713,10 @@ def _get_files_diff(orig_file, new_file, as_string=False, skip_header=True): def _calculate_hash(path): """Calculate the MD5 hash of a file""" + + if not os.path.exists(path): + return None + hasher = hashlib.md5() try: @@ -889,7 +893,7 @@ def _get_journalctl_logs(service): import traceback return "error while get services logs from journalctl:\n%s" % traceback.format_exc() - + def manually_modified_files_compared_to_debian_default(): # from https://serverfault.com/a/90401