Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 19, 2025

AzCopy fails to download files with long paths on Windows systems that have long filename support enabled. The issue occurs because temporary download paths are not converted to use Windows extended path format (\\?\ prefix), while the final destination paths already use this format correctly.

Problem

When AZCOPY_DOWNLOAD_TO_TEMP_PATH=true (the default), AzCopy downloads files to temporary locations with names like .azDownload-<jobID>-<filename> before renaming them to the final destination. However, these temporary paths were constructed using filepath.Join() without applying the Windows long path prefix, causing file creation to fail with:

DOWNLOADFAILED: File Creation Error destination file has no known flags that could cause issue (current set: 0) and azcopy was unable to clear the flag(s), so access will be denied: The filename, directory name, or volume label syntax is incorrect.
   Dst: \\?\D:\longfilename_test\test_very_long_file_data_90_00000000000000000000000000000000000000000000000000000000000000000000000000000000000_data_inputname_100_00000000000000000000000000000000000000000000000000000000000000000000000000000000000000.csv.zip

Solution

Modified the getDownloadPath() function in ste/xfer-remoteToLocal-file.go to ensure temporary download paths also use the Windows extended path format by applying common.ToExtendedPath() to the constructed temporary path.

Before:

tempPath := filepath.Join(parent, fileName)
return tempPath

After:

tempPath := filepath.Join(parent, fileName)
return common.ToExtendedPath(tempPath)

This ensures both temporary and final destination paths consistently use the \\?\ prefix format that Windows requires for paths exceeding 260 characters.

Testing

Added comprehensive unit tests covering:

  • Long path scenarios on Windows
  • Short path compatibility (no regression)
  • Direct download mode when temp paths are disabled
  • Zero-size file handling

The fix is cross-platform safe as ToExtendedPath() only applies the extended format on Windows and returns paths unchanged on other operating systems.

Fixes #3210.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] AzCopy Cannot Handle Long File Paths on Windows enabled long file name Fix long file path handling on Windows when downloading to temporary locations Sep 19, 2025
Copilot AI requested a review from vibhansa-msft September 19, 2025 05:37
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.

AzCopy Cannot Handle Long File Paths on Windows enabled long file name

2 participants