From b3a715a3b9d659d017f1cfd75a8704456faa46ae Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 22 Nov 2012 14:45:59 +0100 Subject: [PATCH] storage: fix _atomic_write to create hidden temporary files (#2010) --- wcs/qommon/storage.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wcs/qommon/storage.py b/wcs/qommon/storage.py index 9851d1525..2be65ff29 100644 --- a/wcs/qommon/storage.py +++ b/wcs/qommon/storage.py @@ -51,7 +51,9 @@ def atomic_write(path, content, async=False): '''Rewrite a complete file automatically, that is write to new file with temporary name, fsync, then rename to final name. Use threads to remove blocking.''' def doit(): - fd, temp = tempfile.mkstemp(dir=os.path.dirname(path), prefix=os.path.basename(path)) + dirname = os.path.dirname(path) + fd, temp = tempfile.mkstemp(dir=dirname, + prefix='.tmp-'+os.path.basename(path)+'-') f = os.fdopen(fd, "w") if hasattr(content, 'read'): # file pointer