support: Workaround for tempdir on different mount.

This adds a workaround for setups where the user has checked out the project on a different mount point than where the temporary directory is located.
This commit is contained in:
Michael Schwarz 2015-07-12 18:57:21 +02:00
parent 8d697f0784
commit 3d21efd489

View file

@ -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