Skip to content

Use pathlib to create tempdir - #1982

Open
r42-chun wants to merge 5 commits into
ynput:developfrom
r42-chun:create_temp_folders_with_pathlib
Open

Use pathlib to create tempdir#1982
r42-chun wants to merge 5 commits into
ynput:developfrom
r42-chun:create_temp_folders_with_pathlib

Conversation

@r42-chun

@r42-chun r42-chun commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Changelog Description

Updated the _create_local_staging_dir function to use pathlib.

This is because if the temp directory is on a different os server, for example if the function is ran on a windows computer to create a temp file on a linux server, the permissions isn't inherited correctly from the parent folder which causes the writing of the file to the temp directory to error.

Testing notes:

  1. start with this step
    Create a review from 3dsmax with a temp directory set on another os server with the environment variable AYON_TMPDIR.
  2. follow this step
    Check if it works

@ynbot ynbot added the size/XS label Aug 4, 2026
@BigRoy
BigRoy requested review from Copilot and iLLiCiTiT August 4, 2026 12:51
@BigRoy BigRoy added type: enhancement Improvement of existing functionality or minor addition sponsored This is directly sponsored by a client or community member labels Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates ayon_core.pipeline.tempdir to create staging temp directories using pathlib instead of tempfile.mkdtemp, aiming to improve permission inheritance when the temp root is on a different OS/fileserver (e.g., AYON_TMPDIR pointing to a cross-OS share).

Changes:

  • Replaced tempfile.mkdtemp(...) with manual Path(...).mkdir(...) creation in _create_local_staging_dir.
  • Introduced UUID-based folder naming to ensure uniqueness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +79
if dirpath is None:
dirpath = tempfile.gettempdir()

base_dir = Path(dirpath)
unique_id = str(uuid.uuid4().hex[:8])
folder_name = f"{prefix or ''}{unique_id}{suffix or ''}"
tmpdir = base_dir / folder_name
tmpdir.mkdir(parents=True, exist_ok=False)

return str(tmpdir)
Comment thread client/ayon_core/pipeline/tempdir.py Outdated
Comment thread client/ayon_core/pipeline/tempdir.py Outdated
r42-chun and others added 2 commits August 5, 2026 10:05
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Comment thread client/ayon_core/pipeline/tempdir.py Outdated
Comment thread client/ayon_core/pipeline/tempdir.py Outdated
r42-chun and others added 2 commits August 7, 2026 10:54
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS sponsored This is directly sponsored by a client or community member type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants