From: Christian Heller Date: Thu, 26 Jan 2017 00:33:48 +0000 (+0100) Subject: Fix bug occuring when trying to append to non-existant file. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/template?a=commitdiff_plain;h=53f2a78496fe73750f729b3c5e4949e528745b65;p=url-catcher Fix bug occuring when trying to append to non-existant file. --- diff --git a/url_catcher.py b/url_catcher.py index ca0974f..0121896 100755 --- a/url_catcher.py +++ b/url_catcher.py @@ -49,7 +49,7 @@ os.makedirs(lists_dir, exist_ok=True) def atomic_write(path, content, mode): """Atomic write/append to file.""" _, tmpPath = tempfile.mkstemp() - if 'a' == mode: + if 'a' == mode and os.path.exists(path): shutil.copy2(path, tmpPath) f = open(tmpPath, mode) f.write(content)