Skip to content
Snippets Groups Projects
Commit 34477c55 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Try and use a potentially-useful suffix to our temporary directory.

parent 73fcc760
No related branches found
No related tags found
Loading
......@@ -18,6 +18,7 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
import re
import sys
import shutil
import logging
......@@ -86,8 +87,22 @@ def clean_all_temp_files():
def _get_base_temporary_directory():
global _BASEDIR
if _BASEDIR is None:
try:
# Try and generate a potentially-useful suffix to our temporary directory
suffix = "_{}".format(
re.sub(
r"[^\w]",
"",
os.path.basename(os.path.dirname(sys.argv[-1])),
)[-10:]
)
except IndexError:
suffix = ""
_BASEDIR = tempfile.TemporaryDirectory(
dir=tempfile.gettempdir(), prefix="diffoscope_"
dir=tempfile.gettempdir(),
prefix="diffoscope_",
suffix=suffix,
)
logger.debug(
"Created top-level temporary directory: %s (free space: %s)",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment