修复 Windows 安装脚本无法识别已移动的 Downloads 目录 #333
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug 背景
用户将 Downloads 目录从默认位置
C:\Users\xxx\Downloads移动到自定义位置(如D:\Downloads)后,安装脚本仍将 chsrc 下载到原默认路径,导致文件位置错误或下载失败。相关 issue: #306
Bug 原因
installer.ps1使用硬编码的${HOME}\Downloads作为默认安装路径,未检测 Windows 系统中 Downloads 文件夹的实际位置。方案
实现三层回退机制:
-d参数覆盖实现
新增
Get_Downloads_Dir函数:HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders读取 Downloads GUID{374DE290-123F-4565-9164-39C4925E467B}$null触发回退修改
Set_Install_Dir函数:$Directory为$null时自动检测其他调整:
$Directory默认值从"${HOME}\Downloads"改为$null$default_install_dir变量$PWD.Path替代Get-Location管道以提升性能Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.