home · contact · privacy
Fix bug occuring when trying to append to non-existant file.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 26 Jan 2017 00:33:48 +0000 (01:33 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 26 Jan 2017 00:33:48 +0000 (01:33 +0100)
url_catcher.py

index ca0974fc70c118127626a768b4c9889abcf017fb..0121896e997924f14e55d5dab3af7531df1b2e15 100755 (executable)
@@ -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)