Skip to content

Commit c75e86f

Browse files
JonZeollaclaude
andcommitted
fix: normalize zip paths to backslashes for \\?\ prefix on Windows
The \\?\ extended-length path prefix requires backslashes and no trailing slashes. Zip entries use forward slashes which must be converted to OS-native separators before joining with the prefix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c985fce commit c75e86f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,23 @@ jobs:
140140
python -c @"
141141
import zipfile, os, sys
142142
zf = zipfile.ZipFile(sys.argv[1])
143-
dest = sys.argv[2]
144-
# Use extended-length path prefix to bypass NTFS char restrictions
145-
if os.name == 'nt':
146-
dest = '\\\\?\\' + os.path.abspath(dest)
143+
raw_dest = sys.argv[2]
144+
# Use extended-length path prefix to bypass NTFS char restrictions.
145+
# The prefix requires backslashes and no trailing slashes.
146+
prefix = '\\\\?\\' + os.path.abspath(raw_dest) if os.name == 'nt' else raw_dest
147147
for info in zf.infolist():
148-
target = os.path.join(dest, info.filename)
148+
# Normalize zip forward slashes to OS path separators
149+
clean = info.filename.replace('/', os.sep).rstrip(os.sep)
150+
target = os.path.join(prefix, clean)
149151
if info.is_dir():
150152
os.makedirs(target, exist_ok=True)
151153
else:
152154
os.makedirs(os.path.dirname(target), exist_ok=True)
153155
with zf.open(info) as src, open(target, 'wb') as dst:
154156
dst.write(src.read())
155-
# Print the top-level directory (without the \\?\ prefix)
156-
raw_dest = sys.argv[2]
157-
print(os.path.join(raw_dest, os.listdir(dest)[0]))
157+
# Print the top-level directory (without the \\?\ prefix for downstream use)
158+
top = os.listdir(prefix)[0]
159+
print(os.path.join(raw_dest, top))
158160
"@ $zipPath $extractDir | Set-Variable templateDir
159161
160162
uvx --with gitpython cookiecutter $templateDir.Trim() --no-input --output-dir "$env:RUNNER_TEMP"

0 commit comments

Comments
 (0)