summaryrefslogtreecommitdiff
path: root/support/lib
diff options
context:
space:
mode:
Diffstat (limited to 'support/lib')
-rw-r--r--support/lib/util.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/support/lib/util.py b/support/lib/util.py
index 45ecb89..3c5117d 100644
--- a/support/lib/util.py
+++ b/support/lib/util.py
@@ -5,9 +5,21 @@ class UserError(Exception):
pass
+def _temp_dir_is_on_same_mount_point():
+ tempdir_stat = os.stat(tempfile.gettempdir())
+ working_dir_stat = os.stat('.')
+
+ return tempdir_stat.st_dev == working_dir_stat.st_dev
+
+
@contextlib.contextmanager
def TemporaryDirectory():
- dir = tempfile.mkdtemp()
+ if _temp_dir_is_on_same_mount_point():
+ dir = None
+ else:
+ dir = '.'
+
+ dir = tempfile.mkdtemp(dir = dir, prefix = '.tmp_')
try:
yield dir