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

Add support for multi-connection downloads via aria2c #2312

Merged
merged 19 commits into from
Aug 7, 2018
Merged

Add support for multi-connection downloads via aria2c #2312

merged 19 commits into from
Aug 7, 2018

Conversation

r15ch13
Copy link
Member

@r15ch13 r15ch13 commented Jun 15, 2018

This change adds support for multi-connection downloads via aria2c. (requested in #2306)
Scoop will use aria2 by default if it's installed locally or globally to speed all downloads.

  • Support current cache behaviour
  • Disable aria2 via scoops config (scoop config enable_aria2 false)
  • Added some color to the installation output
  • Proxy support (need someone who can test which proxy settings are required)
  • Change aria2 parameters via scoops config

The output changes from the previous progress bar to simply writing the aria2 output.

aria2-scoop-demo
still image

Use the following command for constant tests:
.\bin\scoop.ps1 uninstall godot; .\bin\scoop.ps1 cache rm godot; .\bin\scoop.ps1 install godot

Copy link
Member

@rasa rasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

lib/core.ps1 Outdated
}

# global path to executable
$aria2 = "$(versiondir 'aria2' 'current' $false)\aria2c.exe"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as line 97. Shouldn’t $false be $true here?

$has_downloads = $false

# aria2 options
$options = @(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users may want to tweak these defaults. Let’s add a config setting eventually.

Copy link
Member Author

@r15ch13 r15ch13 Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use Scoops config settings or use a custom aria2.conf? Should we allow aria2 to load the config file from HOME or disable it with --no-conf?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions. I would say allow aria2 to use its default config file ($HOME/.aria2/aria2.conf or $XDG_CONFIG_HOME/aria2/aria2.conf if not found, $XDG_CONFIG_HOME defaults to $HOME/.config, see https://github.com/aria2/aria2/blob/e0a827ff98e665a118e2001dfe29b14847a33070/src/util.cc#L1808 )
In addition, perhaps we have a config setting, say aria2_options, to define scoop specific options?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The desire behaviour must be scoop config taking precedence over aria2.conf. Maybe via script merge aria2.conf with scoop config and create new config file to get this behaviour. Things like number of pieces of downloads should be exposed on root of scoop config.

Thx

lib/install.ps1 Outdated
return
}
Write-Host $prefix -NoNewline
if($_.EndsWith('download completed.')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fail if aria2’s language isn’t English.

@JasCodes
Copy link

Error report:

Installing 'dbeaver' (5.1.1) [64bit]
Starting download with aria2 ...
Download: [#0e0a4c 0B/0B CN:1 DL:0B]
Download: 06/19 20:36:54 [ERROR] CUID#7 - Download aborted. URI=https://dbeaver.jkiss.org/files/5.1.1/dbeaver-ce-5.1.1-win32.win32.x86_64.zip
Download: Exception: [AbstractCommand.cc:351] errorCode=22 URI=https://dbeaver.io/files/5.1.1/dbeaver-ce-5.1.1-win32.win32.x86_64.zip
Download:   -> [HttpSkipResponseCommand.cc:240] errorCode=22 The response status is not successful. status=400
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 0e0a4c|ERR |       0B/s|C:/Users/jas/scoop/cache/dbeaver#5.1.1#https_dbeaver.jkiss.org_files_5.1.1_dbeaver-ce-5.1.1-win32.win32.x86_64.zip
Download: Status Legend:
Download: (ERR):error occurred.
Download: aria2 will resume download if the transfer is restarted.
Download: If there are any errors, then see the log file. See '-l' option in help/man page for details.
ERROR Download failed!
DEBUG https://dbeaver.jkiss.org/files/5.1.1/dbeaver-ce-5.1.1-win32.win32.x86_64.zip
    out=dbeaver#5.1.1#https_dbeaver.jkiss.org_files_5.1.1_dbeaver-ce-5.1.1-win32.win32.x86_64.zip

DEBUG C:\Users\jas\scoop\apps\aria2\current\aria2c.exe --input-file='C:\Users\jas\scoop\cache\dbeaver.txt' --dir='C:\Users\jas\scoop\cache' --user-agent='Scoop/1.0 (+http://scoop.sh/) PowerShell/5.1 (Windows NT 10.0; Win64; x64; Desktop)' --allow-overwrite=true --auto-file-renaming=false --retry-wait=2 --split=20 --max-connection-per-server=5 --min-split-size=5M --console-log-level=warn --enable-color=false

@r15ch13
Copy link
Member Author

r15ch13 commented Jun 23, 2018

@Jas99 that is actually a problem with dbeaver. dbeaver.jkiss.org redirects to dbeaver.io and causes a 400 Bad Request with aria2. Changing the URL to dbeaver.io works. (fixed in ScoopInstaller/Extras@b227cd2)

@rasa
Copy link
Member

rasa commented Jun 23, 2018

It sure doesn’t jump out in the error message it’s a 400 error, does it?

@r15ch13
Copy link
Member Author

r15ch13 commented Jun 25, 2018

@Jas99

New scoop settings (prepend aria2- to each aria2 option):

aria2-enabled                   (default: true)
aria2-retry-wait                (default: 2)
aria2-split                     (default: 5)
aria2-max-connection-per-server (default: 5)
aria2-min-split-size            (default: 5M)

@rasa
Copy link
Member

rasa commented Jun 25, 2018

@r15ch13 Looks great! We may want to eventually add an aria2-options to allow users to specify options we haven’t provided them access to. For example:

scoop config aria2-options “--all-proxy=<proxy> --connect-timeout=<sec>”

@r15ch13
Copy link
Member Author

r15ch13 commented Jun 25, 2018

@rasa like this? 😄

@rasa
Copy link
Member

rasa commented Jun 25, 2018

@r15ch13 Lgtm!

@yqu212
Copy link

yqu212 commented Jun 26, 2018

@r15ch13 Good job. Thanks.

Can a user specify a proxy for each app? For example,

scoop install vim --http-proxy="http://proxy"

A global proxy is not suitable for each situation. Some apps need not proxy.

@r15ch13
Copy link
Member Author

r15ch13 commented Jun 26, 2018

@yqu212 this is not even supported by the current installation process. This is something for another feature i guess. 😄

@yqu212
Copy link

yqu212 commented Jun 26, 2018

@r15ch13 Ok. I see. By the way, when will this pull request be merged into the master branch?

@xeijin
Copy link
Contributor

xeijin commented Jul 14, 2018

This is great, I do miss the wget-style [======> ] progress bar though :( a quick play around with aria2c seems to suggest it doesn't have something similar implemented.

@xeijin
Copy link
Contributor

xeijin commented Jul 15, 2018

Did this end up going in? Just noticed some of the appveyor tests failed

Sent with GitHawk

@DesigningKnights
Copy link

Is this going in soon ?

@r15ch13
Copy link
Member Author

r15ch13 commented Aug 2, 2018

Currently, I don't have the time and information I need to implement the Proxy part of this. It would be great If someone could test this with different proxy settings. 😄

@se35710
Copy link
Contributor

se35710 commented Aug 3, 2018

@r15ch13 I have tested with nginx (no Connect support, so all tls connections fail), and with squid (with connect support), and it's working great!

C:> .\bin\scoop.ps1 config proxy 172.16.1.254:3128
C:> .\bin\scoop.ps1 install eclipse-javascript
Installing 'eclipse-javascript' (4.8.0) [64bit]
Starting download with aria2 ...
Download: [#5cb76c 0B/0B CN:1 DL:0B]
Download: [#5cb76c 704KiB/172MiB(0%) CN:5 DL:792KiB ETA:3m41s]
Download: [#5cb76c 14MiB/172MiB(8%) CN:5 DL:7.4MiB ETA:21s]
Download: [#5cb76c 32MiB/172MiB(18%) CN:5 DL:11MiB ETA:12s]
Download: [#5cb76c 51MiB/172MiB(29%) CN:5 DL:13MiB ETA:9s]
Download: [#5cb76c 69MiB/172MiB(40%) CN:5 DL:14MiB ETA:7s]
Download: [#5cb76c 88MiB/172MiB(51%) CN:5 DL:15MiB ETA:5s]
Download: [#5cb76c 105MiB/172MiB(61%) CN:5 DL:15MiB ETA:4s]
Download: [#5cb76c 122MiB/172MiB(71%) CN:5 DL:15MiB ETA:3s]
Download: [#5cb76c 140MiB/172MiB(81%) CN:5 DL:15MiB ETA:2s]
Download: [#5cb76c 152MiB/172MiB(88%) CN:4 DL:15MiB ETA:1s]
Download: [#5cb76c 157MiB/172MiB(91%) CN:4 DL:15MiB]
Download: [#5cb76c 163MiB/172MiB(94%) CN:3 DL:14MiB]
Download: [#5cb76c 170MiB/172MiB(99%) CN:1 DL:13MiB]
Download: [#5cb76c 171MiB/172MiB(99%) CN:1 DL:11MiB]
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 5cb76c|OK  |    11MiB/s|C:/Users/mathi/scoop/cache/eclipse-javascript#4.8.0#https_www.eclipse.org_downloads_download.php_file_technology_epp_downloads_release_photon_R_eclipse-javascript-photon-R-win32-x86_64.zip_r_1_dl.7z
Download: Status Legend:
Download: (OK):download completed.
Checking hash of download.php ... ok.
Extracting dl.7z ... done.
Linking ~\scoop\apps\eclipse-javascript\current => ~\scoop\apps\eclipse-javascript\4.8.0
Creating shortcut for Eclipse IDE for JavaScript and Web Developers (eclipse.exe)
'eclipse-javascript' (4.8.0) was installed successfully!

C:> .\bin\scoop.ps1 config proxy 172.16.1.250:3128
C:> .\bin\scoop.ps1 uninstall eclipse-javascript ; .\bin\scoop.ps1 cache rm eclipse-javascript ; .\bin\scoop.ps1 install eclipse-javascript
Installing 'eclipse-javascript' (4.8.0) [64bit]
Starting download with aria2 ...
Download: 08/04 00:13:09 [ERROR] CUID#7 - Download aborted. URI=https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip&r=1#/dl.7z
Download: Exception: [AbstractProxyResponseCommand.cc:75] errorCode=1 Proxy connection failed.
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 4637ce|ERR |       0B/s|C:/Users/mathi/scoop/cache/eclipse-javascript#4.8.0#https_www.eclipse.org_downloads_download.php_file_technology_epp_downloads_release_photon_R_eclipse-javascript-photon-R-win32-x86_64.zip_r_1_dl.7z
Download: Status Legend:
Download: (ERR):error occurred.
Download: aria2 will resume download if the transfer is restarted.
Download: If there are any errors, then see the log file. See '-l' option in help/man page for details.
ERROR Download failed! (Error 1) An unknown error occurred
DEBUG https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip&r=1#/dl.7z
    referer=https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip&r=1#/
    dir=C:\Users\mathi\scoop\cache
    out=eclipse-javascript#4.8.0#https_www.eclipse.org_downloads_download.php_file_technology_epp_downloads_release_photon_R_eclipse-javascript-photon-R-win32-x86_64.zip_r_1_dl.7z

DEBUG C:\Users\mathi\scoop\apps\aria2\current\aria2c.exe --input-file='C:\Users\mathi\scoop\cache\eclipse-javascript.txt' --user-agent='Scoop/1.0 (+http://scoop.sh/) PowerShell/5.1 (Windows NT 10.0; Win64; x64; Desktop)' --allow-overwrite=true --auto-file-renaming=false --retry-wait=2 --split=5 --max-connection-per-server=5 --min-split-size=5M --console-log-level=warn --enable-color=false --no-conf=true --all-proxy='172.16.1.250:3128'

C:> .\bin\scoop.ps1 install foxe
Installing 'foxe' (2.4.2) [64bit]
Starting download with aria2 ...
Download: [#26f82d 64KiB/403KiB(15%) CN:1 DL:91KiB ETA:3s]
Download: [#26f82d 352KiB/403KiB(87%) CN:1 DL:199KiB]
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 26f82d|OK  |   219KiB/s|C:/Users/mathi/scoop/cache/foxe#2.4.2#http_www.firstobject.com_foxe242.zip
Download: Status Legend:
Download: (OK):download completed.
Checking hash of foxe242.zip ... ok.
Extracting foxe242.zip ... done.
Linking ~\scoop\apps\foxe\current => ~\scoop\apps\foxe\2.4.2
Creating shim for 'foxe'.
'foxe' (2.4.2) was installed successfully!

squid logs:

1533334064.145   4761 172.16.1.16 TCP_TUNNEL/200 4679 CONNECT www.eclipse.org:443 - HIER_DIRECT/198.41.30.198 -
1533334064.447   3908 172.16.1.16 TCP_TUNNEL/200 517 CONNECT www.eclipse.org:443 - HIER_DIRECT/198.41.30.198 -
1533334064.480   3940 172.16.1.16 TCP_TUNNEL/200 4224 CONNECT www.eclipse.org:443 - HIER_DIRECT/198.41.30.198 -
1533334064.486   3945 172.16.1.16 TCP_TUNNEL/200 4221 CONNECT www.eclipse.org:443 - HIER_DIRECT/198.41.30.198 -
1533334065.603   1969 172.16.1.16 TCP_MISS/206 21283895 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334067.356   1748 172.16.1.16 TCP_MISS/206 16777721 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334068.664   1304 172.16.1.16 TCP_MISS/206 15729143 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334069.323    655 172.16.1.16 TCP_MISS/206 7340534 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334069.844   8727 172.16.1.16 TCP_MISS_ABORTED/206 28315953 GET http://mirror.switch.ch/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/130.59.113.36 application/zip
1533334069.907    578 172.16.1.16 TCP_MISS/206 6291958 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334071.982  11673 172.16.1.16 TCP_MISS_ABORTED/200 22066802 GET http://mirror.switch.ch/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/130.59.113.36 application/zip
1533334072.206  10763 172.16.1.16 TCP_MISS_ABORTED/206 7294448 GET http://mirror.switch.ch/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/130.59.113.36 application/zip
1533334072.839    632 172.16.1.16 TCP_MISS/206 4273174 GET http://mirror.dkm.cz/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/86.49.49.49 application/zip
1533334073.071   3212 172.16.1.16 TCP_MISS/206 6291889 GET http://mirror.switch.ch/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/130.59.113.36 application/zip
1533334074.956  13532 172.16.1.16 TCP_MISS_ABORTED/206 16781618 GET http://mirror.switch.ch/eclipse/technology/epp/downloads/release/photon/R/eclipse-javascript-photon-R-win32-x86_64.zip - HIER_DIRECT/130.59.113.36 application/zip

nginx logs:

172.16.1.16 - - [04/Aug/2018:00:13:09 +0200] "CONNECT www.eclipse.org:443 HTTP/1.1" 400 182 "-" "-"
172.16.1.16 - - [04/Aug/2018:00:13:09 +0200] "CONNECT www.eclipse.org:443 HTTP/1.1" 400 182 "-" "-"
172.16.1.16 - - [04/Aug/2018:00:13:09 +0200] "CONNECT www.eclipse.org:443 HTTP/1.1" 400 182 "-" "-"
172.16.1.16 - - [04/Aug/2018:00:13:09 +0200] "CONNECT www.eclipse.org:443 HTTP/1.1" 400 182 "-" "-"
172.16.1.16 - - [04/Aug/2018:00:13:09 +0200] "CONNECT www.eclipse.org:443 HTTP/1.1" 400 182 "-" "-"
172.16.1.16 - - [04/Aug/2018:00:16:09 +0200] "GET http://www.firstobject.com/foxe242.zip HTTP/1.1" 200 412759 "http://www.firstobject.com/" "Scoop/1.0 (+http://scoop.sh/) PowerShell/5.1 (Windows NT 10.0; Win64; x64; Desktop)"

@se35710
Copy link
Contributor

se35710 commented Aug 3, 2018

sourceforge is broken though, both with and without proxy defined:

C:> .\bin\scoop.ps1 install console2
Installing 'console2' (2.0.0.148) [64bit]
Starting download with aria2 ...
Download: [#81c45a 0B/0B CN:1 DL:0B]
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: 81c45a|OK  |   400KiB/s|C:/Users/mathi/scoop/cache/console2#2.0.0.148#https_downloads.sourceforge.net_project_console_console-devel_2.00_Console-2.00b148-Beta_64bit.zip
Download: Status Legend:
Download: (OK):download completed.
Checking hash of Console-2.00b148-Beta_64bit.zip ... ERROR Hash check failed!
App:       extras/console2
URL:       https://downloads.sourceforge.net/project/console/console-devel/2.00/Console-2.00b148-Beta_64bit.zip
Expected:  675c3c82695a97dafe164960a50dfbe6c13d0a900b382efb7090090138d22933
Actual:    ce421ad8395690a3df8901fdbef785537bbfc94793dfa25160719d650884e529

Manually downloading it with aria2 works, and gives the correct checksum. I have tested with multiple sourceforge projects, they all get checksum errors with aria2 when running scoop install.

lib/install.ps1 Outdated
$has_downloads = $true
# create aria2 input file content
$urlstxt_content += "$url`n"
$urlstxt_content += " referer=$(strip_filename $url)`n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix sourceforge checksum errors:

        if(!(test-path $data.$url.source)) {
            $has_downloads = $true
            # create aria2 input file content
            $urlstxt_content += "$url`n"
            if (-not ($url -imatch "//downloads.sourceforge.net/")) {
                $urlstxt_content += "    referer=$(strip_filename $url)`n"
            }
            $urlstxt_content += "    dir=$cachedir`n"
            $urlstxt_content += "    out=$($data.$url.cachename)`n"
        } else {

@r15ch13
Copy link
Member Author

r15ch13 commented Aug 7, 2018

@se35710 can you provide your proxy settings for nginx/squid so I can test this? Or should I merge this and fix the proxy stuff later? 😁

@r15ch13 r15ch13 merged commit 8c77bf7 into master Aug 7, 2018
@r15ch13 r15ch13 deleted the aria2 branch August 7, 2018 18:15
@se35710
Copy link
Contributor

se35710 commented Aug 7, 2018

@r15ch13 Here they are: 😃

nginx:

server {
        listen 3128 default_server;
        listen [::]:3128 default_server;
        server_name _;
        location / {
                resolver 8.8.8.8 8.8.4.4;
                proxy_pass http://$http_host$uri$is_args$args;
        }
}

and squid.conf:

acl localnet src 10.0.0.0/8
acl localnet src 172.16.0.0/12
acl localnet src 192.168.0.0/16
acl localnet src fc00::/7
acl localnet src fe80::/10

acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT

http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
http_access deny all

http_port 3128

dns_nameservers 8.8.8.8 8.8.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants