Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fail to download app with long url in manifest #5606

Closed
iamhyc opened this issue Aug 11, 2023 · 1 comment
Closed

[Bug] Fail to download app with long url in manifest #5606

iamhyc opened this issue Aug 11, 2023 · 1 comment
Labels

Comments

@iamhyc
Copy link

iamhyc commented Aug 11, 2023

Bug Report

Current Behavior

With the example manifest here, the current scoop (v0.3.1) will give the error messages pasted below and fail to download the software.

Expected Behavior

The software should be downloaded in the cache folder.

Additional context/output

PS > scoop install deveco-studio
Installing 'deveco-studio' (4.0.0.400) [64bit] from sudofree-bucket bucket

文件名、目录名或卷标语法不正确。 : 'C:\Users\iamhy\scoop\cache\deveco-studio#4.0.0.400#https_contentcenter-vali-drcn.dbankcdn.cn_pvt_2_DeveloperAlliance_package_901_9_9b_v3_2g1w9tlbQPevu9IkTNRhNw_devecostudio-windows-4.0.0.400.zip_HW-CC-KV_V1_HW-CC-Date_20230804T022932Z_HW-CC-Expire_315360000_HW-CC-Sign_23242113800451447FF87450B938F6B3A3B27A7360C10FBF7BCAB10B24473326.download'
URL https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_package_901_9/9b/v3/2g1w9tlbQPevu9IkTNRhNw/devecostudio-windows-4.0.0.400.zip?HW-CC-KV=V1&HW-CC-Date=20230804T022932Z&HW-CC-Expire=315360000&HW-CC-Sign=23242113800451447FF87450B938F6B3A3B27A7360C10FBF7BCAB10B24473326 is not valid

I tried to make powershell output en-US error message but failed. For your convenience, "文件名、目录名或卷标语法不正确" means "The filename directory name or volume label syntax is incorrect".

Possible Solution

I find the error happens because [io.file]::openwrite on "lib/install.ps1#L435" fails to handle the long path name and raises a PathTooLongException.
As a workaround, I truncate the cached full path length to 260.

diff --git a/lib/install.ps1 b/lib/install.ps1
index cdbfdf1a..0ab1d49c 100644
--- a/lib/install.ps1
+++ b/lib/install.ps1
@@ -82,6 +82,7 @@ function install_app($app, $architecture, $global, $suggested, $use_cache = $tru

 function Invoke-CachedDownload ($app, $version, $url, $to, $cookies = $null, $use_cache = $true) {
     $cached = fullpath (cache_path $app $version $url)
+    $cached = $cached.subString(0, [System.Math]::min(260, $cached.Length))

     if(!(test-path $cached) -or !$use_cache) {
         ensure $cachedir | Out-Null

System details

Windows version: 10

OS architecture: 64bit

PowerShell version: 7.3.6

Additional software: N/A

Scoop Configuration

{
  "aria2-warning-enabled": false,
  "aria2-enabled": false,
  "last_update": "2023-08-11T18:46:19.5948020+08:00",
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop",
  "scoop_branch": "master"
}
@iamhyc iamhyc added the bug label Aug 11, 2023
@rashil2000
Copy link
Member

Duplicate of #4327

@rashil2000 rashil2000 marked this as a duplicate of #4327 Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants