Skip to content

SG-44086 Unzip long paths#1118

Open
carlos-villavicencio-adsk wants to merge 5 commits into
masterfrom
ticket/SG-44086_unzip_long_paths
Open

SG-44086 Unzip long paths#1118
carlos-villavicencio-adsk wants to merge 5 commits into
masterfrom
ticket/SG-44086_unzip_long_paths

Conversation

@carlos-villavicencio-adsk

Copy link
Copy Markdown
Contributor

This pull request enhances the zip extraction utilities to better support long file paths on Windows by introducing handling for extended-length paths. The main changes ensure that file and directory operations during extraction bypass the Windows MAX_PATH limitation.

Windows extended-length path support:

The registry key alone isn't enough - Python's zipfile module doesn't use extended-length paths (\?) automatically. The application itself also needs the longPathAware manifest entry, and the bundled FPT Desktop Python likely doesn't have it.

The real fix needs to be in tk-core's zip utility: prefix to file paths longer than 260 characters on Windows, allowing the code to work with very long paths.

What if FPT desktop enables longPathAware manifest someday

The fix is still worth keeping for these reasons:

  • No system config required - The \\?\ approach works on any Windows machine regardless of registry settings or manifest, so users don't need to do anything extra.

  • Defense in depth - The longPathAware + registry approach requires both to be true simultaneously. If either is missing (e.g., customer hasn't set the registry key, or the bundled Python doesn't have the manifest), the unzip still fails. The \\?\ fix has no such dependencies.

  • Older Python builds - Python 3.6+ includes longPathAware in its manifest, but the Python bundled with older FPT Desktop versions may not. The fix works everywhere.

  • Works without reboot - The \\?\ prefix bypasses the limit at the API call level, no reboot or registry change needed.

Reference

https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.12%. Comparing base (a4d87f0) to head (d16e500).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1118      +/-   ##
==========================================
+ Coverage   80.11%   80.12%   +0.01%     
==========================================
  Files         203      203              
  Lines       19549    19561      +12     
==========================================
+ Hits        15662    15674      +12     
  Misses       3887     3887              
Flag Coverage Δ
Linux 79.56% <41.66%> (-0.03%) ⬇️
Python-3.10 79.93% <100.00%> (+0.01%) ⬆️
Python-3.11 79.83% <100.00%> (-0.01%) ⬇️
Python-3.13 79.83% <100.00%> (+0.01%) ⬆️
Python-3.9 79.90% <100.00%> (+0.02%) ⬆️
Windows 79.61% <100.00%> (+0.02%) ⬆️
macOS 79.53% <41.66%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@carlos-villavicencio-adsk
carlos-villavicencio-adsk requested a review from a team July 10, 2026 20:54
Comment thread python/tank/util/zip.py Outdated
Comment thread python/tank/util/zip.py Outdated
Comment thread python/tank/util/zip.py Outdated
Comment thread python/tank/util/zip.py

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 PR updates tank.util.zip extraction to better support very long file paths on Windows by introducing a helper that applies the extended-length (\\?\) path prefix during unzip operations.

Changes:

  • Added _to_extended_path() helper to prefix long absolute Windows paths with \\?\ to bypass MAX_PATH.
  • Updated unzip extraction flow to run the computed extraction path through _to_extended_path() before filesystem operations.
  • Added unit tests for _to_extended_path() behavior across platforms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/tank/util/zip.py Introduces _to_extended_path() and applies it during per-item extraction to enable long-path handling on Windows.
tests/util_tests/test_zip.py Adds targeted tests to validate _to_extended_path() behavior on Windows and non-Windows platforms.

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

Comment thread python/tank/util/zip.py
Comment thread tests/util_tests/test_zip.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants