From d3f7809fb43fa36e672cccaf14f2a33da6e82dd6 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Tue, 29 May 2018 08:55:58 +0200 Subject: [PATCH] [fix] redo yolo logic in case file doesn't exist --- src/yunohost/service.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index b252f0873..100150c21 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -698,11 +698,18 @@ def _get_files_diff(orig_file, new_file, as_string=False, skip_header=True): header can also be removed if skip_header is True. """ - with open(orig_file, 'r') as orig_file: - orig_file = orig_file.readlines() - with open(new_file, 'r') as new_file: - new_file.readlines() + if os.path.exists(orig_file): + with open(orig_file, 'r') as orig_file: + orig_file = orig_file.readlines() + else: + orig_file = [] + + if not os.path.exists(new_file): + with open(new_file, 'r') as new_file: + new_file.readlines() + else: + new_file = [] # Compare files and format output diff = unified_diff(orig_file, new_file)