From 53f2a78496fe73750f729b3c5e4949e528745b65 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 26 Jan 2017 01:33:48 +0100 Subject: [PATCH] Fix bug occuring when trying to append to non-existant file. --- url_catcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- 2.30.2