From 795dd7f700b6a86bd5bf31a2f00a76a2dc74bb23 Mon Sep 17 00:00:00 2001
From: David Stainton <dstainton415@gmail.com>
Date: Mon, 5 Oct 2015 12:59:58 +0200
Subject: [PATCH] For all downloaded files ensure parent dir exists

---
 src/allmydata/frontends/magic_folder.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py
index 422a7c11..e0327a18 100644
--- a/src/allmydata/frontends/magic_folder.py
+++ b/src/allmydata/frontends/magic_folder.py
@@ -578,6 +578,11 @@ class Downloader(QueueMixin):
         if now is None:
             now = time.time()
 
+        # ensure parent directory exists
+        head, tail = os.path.split(abspath_u)
+        mode = 0777 # XXX
+        fileutil.make_dirs(head, mode)
+
         fileutil.write(replacement_path_u, file_contents)
         os.utime(replacement_path_u, (now, now - cls.FUDGE_SECONDS))
         if is_conflict:
-- 
2.45.2