From 5c2075cb6cb23b15fe3a3bee5b69416a6aed6fa2 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 8 Aug 2016 14:55:01 +0200 Subject: [PATCH] Fix _atomic_write --- radicale/storage.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/radicale/storage.py b/radicale/storage.py index 730e691..c04f2ef 100644 --- a/radicale/storage.py +++ b/radicale/storage.py @@ -392,8 +392,9 @@ class Collection(BaseCollection): @contextmanager def _atomic_write(self, path, mode="w"): + directory = os.path.dirname(path) tmp = NamedTemporaryFile( - mode=mode, dir=os.path.dirname(path), encoding=self.encoding, + mode=mode, dir=directory, encoding=self.encoding, delete=False, prefix=".Radicale.tmp-") try: yield tmp @@ -408,7 +409,7 @@ class Collection(BaseCollection): tmp.close() os.remove(tmp.name) raise - self._sync_directory(dir) + self._sync_directory(directory) def _find_available_file_name(self): # Prevent infinite loop