diff options
author | Michael Schwarz <michi.schwarz@gmail.com> | 2015-07-12 18:57:21 +0200 |
---|---|---|
committer | Michael Schwarz <michi.schwarz@gmail.com> | 2015-07-12 18:57:21 +0200 |
commit | 3d21efd4897053e760ad7f4ce14a5482f66e858c (patch) | |
tree | 93907bfcc2d261195f162a83aa98d0f7e3ab8c38 | |
parent | 8d697f07849a4bd37e216b2d070f3c51fd6f0e31 (diff) | |
download | pogojig-3d21efd4897053e760ad7f4ce14a5482f66e858c.tar.gz pogojig-3d21efd4897053e760ad7f4ce14a5482f66e858c.tar.bz2 pogojig-3d21efd4897053e760ad7f4ce14a5482f66e858c.zip |
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.
-rw-r--r-- | support/lib/util.py | 14 |
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 |