From 9f8c1c93872773bb513cfb5f338dbddeea5e8d29 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sun, 16 Sep 2018 20:52:43 +0200 Subject: [PATCH 1/2] fix #14: avoid crashing if storage directory is missing --- diffido.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/diffido.py b/diffido.py index bd47379..614c31d 100755 --- a/diffido.py +++ b/diffido.py @@ -196,7 +196,17 @@ def run_job(id_=None, force=False, *args, **kwargs): req_path = urllib.parse.urlparse(req.url).path base_name = os.path.basename(req_path) or 'index.html' def _commit(id_, filename, content, queue): - os.chdir('storage/%s' % id_) + try: + os.chdir('storage/%s' % id_) + except Exception as e: + logger.info('unable to move to storage/%s directory: %s; trying to create it...' % (id_, e)) + _created = False + try: + _created = git_create_repo(id_) + except Exception as e: + logger.info('unable to move to storage/%s directory: %s; unable to create it' % (id_, e)) + if not _created: + return False current_lines = 0 if os.path.isfile(filename): with open(filename, 'r') as fd: @@ -328,7 +338,8 @@ def get_history(id_, limit=None, add_info=False): def _history(id_, limit, queue): try: os.chdir('storage/%s' % id_) - except: + except Exception as e: + logger.info('unable to move to storage/%s directory: %s' % (id_, e)) return queue.put(b'') cmd = [GIT_CMD, 'log', '--pretty=oneline', '--shortstat'] if limit is not None: @@ -383,7 +394,11 @@ def get_diff(id_, commit_id='HEAD', old_commit_id=None): :returns: information about the schedule and the diff between commits :rtype: dict""" def _history(id_, commit_id, old_commit_id, queue): - os.chdir('storage/%s' % id_) + try: + os.chdir('storage/%s' % id_) + except Exception as e: + logger.info('unable to move to storage/%s directory: %s' % (id_, e)) + return queue.put(b'') p = subprocess.Popen([GIT_CMD, 'diff', old_commit_id or '%s~' % commit_id, commit_id], stdout=subprocess.PIPE) stdout, _ = p.communicate() From fde269c0dd9de5855f4c197994a51746385665f3 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Fri, 2 Nov 2018 08:27:41 +0100 Subject: [PATCH 2/2] remove demo link --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 23a19d4..fb4c9a4 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,6 @@ Spot the difference on the web. Tired of clicking F5 waiting for a change on a web page? Define a list of pages to watch, and receive an email when something has changed. -# Demo - -See [https://ismito.it:3210/](https://ismito.it:3210/) (you can only add \*.wikipedia.org pages, there) - - ## Install, run, develop and debug ## Docker