575 Commits

Author SHA1 Message Date
Mike McQuaid
c4f72312ce
Fixup brew style failures. 2019-04-30 09:19:18 +01:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
4576fb0a68 Force GET for head requests. 2019-04-03 12:08:15 +02:00
Mike McQuaid
20e4262fb9
unpack_strategy: prioritise extension instead.
Instead of only looking at the extension when invoked as part of
Homebrew's formulae' download strategies instead prioritise the
extension if it actually exists. When it does not, fall back to the
magic detection logic which is likely to be more reliable.

Fixes https://github.com/Homebrew/brew/issues/5895
2019-04-03 10:32:29 +01:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
0c44498581
download_strategy: more robust filename content encoding handling.
Fixes #5713.
2019-02-13 13:29:37 +00:00
Markus Reiter
de5b35876f Use Mechanize to parse Content-Disposition. 2019-01-30 04:15:34 +01:00
Kevin Abel
8fddd87472
Resource, CurlDownloadStrategy: Deduplicate the curl HEAD requests
Fixes #5357

* Eliminates getting a new strategy instance via Resource methods
* only call resolve_url_basename_time once and store the time result as
an instance variable for reuse
2018-12-16 13:56:58 -06:00
Chongyu Zhu
6f8d81e780
GitDownloadStrategy: disable automatic tag following 2018-12-12 19:42:12 +08:00
EricFromCanada
5e2f87f7ac CurlDownloadStrategy: handle Location indicating the current dir.
If a response contains a Location header starting with `./`, substitute just final component of the URL path with the given filename.
2018-11-22 19:24:30 -05:00
Markus Reiter
eddbab6a1c
Merge pull request #5217 from reitermarkus/download-time
Check if cached downloads are up-to-date.
2018-11-04 18:06:30 +01:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
Markus Reiter
3d805295eb Check if cached downloads are up-to-date. 2018-11-01 20:29:18 +01:00
Michael Ripley
1f9332611f Nil error when mirror download fails
This issue causes method in a Nil object to be read when a mirror download fails. In my case, this occurs due to my office's proxy blocking certain mirrors. This patch fixes the Nil access, exposing a more helpful error message.

## Before patch
```
$ brew install maven
Error: An exception occurred within a child process:
  NoMethodError: undefined method `unlock' for nil:NilClass
```

## After patch
```
$ brew install maven
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "maven"
Download failed: Couldn't determine mirror, try again later.
```

## Steps to reproduce
1.  Use brew 1.8.0
2.  Ensure maven is not installed:
    ```
    brew remove maven
    ```
3.  Ensure the download is not cached:
    ```
    rm "$HOME/Library/Caches/Homebrew/downloads/*--apache-maven-*-bin.tar.gz"
    ```
4.  Make the mirrors unreachable by pointing them at a nonfunctional proxy:
    ```
    export http{,s}_proxy=http://localhost:8080
    export no_proxy=*.github.com,*.brew.sh
    ```
5.  Attempt package installation
    ```
    brew install maven
    ```
2018-10-29 14:31:37 -05:00
Markus Reiter
b0742db4fa Support Content-Disposition: inline. 2018-10-21 05:56:02 +02:00
Mike McQuaid
599ecc9b5a
Deprecate unused download strategies
Download the unused, private download strategies. These are a better fit
for being declared in the formulae and/or taps that use them rather than
in Homebrew/brew where they are unused by Homebrew maintainers or
official taps/formulae.
2018-10-19 10:48:52 +01:00
EricFromCanada
20167e5f1b Adjust comments to tidy API docs output. 2018-10-18 21:42:43 -04:00
Markus Reiter
1f24c6600c Fix cleanup of incomplete downloads. 2018-10-14 00:15:16 +02:00
Viktor Szakats
041cd039f7 download_strategy: Miscalculated redirect when Location: is protocol-relative 2018-10-07 11:16:33 +00:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Mike McQuaid
955214abc0
Use ActiveSupport Object#blank? and #present? 2018-09-14 17:02:19 +01:00
Markus Reiter
17c3a66265 Change regex to match filename if header also contains filename*. 2018-09-05 02:28:35 +02:00
Markus Reiter
2ca3439ada Fix downloads directory not being created. 2018-09-05 00:38:19 +02:00
Mike McQuaid
bcb1ec5499
Improve Homebrew/brew line length.
Use 124 max line length everywhere. Also, reduce tap max line length to
189 as Homebrew/homebrew-core has that as a maximum now. In future
Homebrew/homebrew-core will also be reduced to 124 maximum line length.
2018-09-02 16:15:09 +01:00
Markus Reiter
e377bdb6fe Fix CurlApacheMirrorDownloadStrategy URL resolution. 2018-09-02 03:30:37 +02:00
Markus Reiter
b54682f709 Avoid network call in #initialize. 2018-09-01 16:20:10 +02:00
Markus Reiter
b63ac557bc Update symlink even if cached_location already exists. 2018-08-31 16:51:23 +02:00
Markus Reiter
9edc355052 Don’t glob for .incomplete downloads. 2018-08-31 16:51:23 +02:00
Markus Reiter
3988458919 Use real basename for output. 2018-08-31 16:51:23 +02:00
Markus Reiter
fbcaa8c85a Resolve URL to get real file extension. 2018-08-31 16:51:23 +02:00
Kevin Abel
584cced003
Remove the chdir call that was already moved to the ancestor
528b4b367ed2a4026c321e2f2e503ace4548b9d2 moved the chdir definition to
the parent class and call it in the parent's stage. chdir was getting
called twice for archives with two nested directories.
2018-08-17 23:13:23 -05:00
Markus Reiter
837f56c73b Use system_command for all download strategies. 2018-08-06 12:32:34 +02:00
Markus Reiter
ac9cd39a4c Merge download strategy specs. 2018-08-06 00:19:54 +02:00
Markus Reiter
1003d722bd Use -- to separate download name and version. 2018-08-05 15:57:28 +02:00
Markus Reiter
545eb91c83
Merge pull request #4599 from reitermarkus/download-cache-directory
Allow specifying cache directory for download strategies.
2018-08-03 19:30:09 +02:00
Markus Reiter
ea281a1cf9 Allow specifying cache directory for download strategies. 2018-08-03 18:04:54 +02:00
Markus Reiter
13c65eed70 Change docs to use symbols instead of class names. 2018-08-03 17:50:57 +02:00
Markus Reiter
de5aa6a23a Move temporary_path to AbstractFileDownloadStrategy. 2018-08-03 15:11:04 +02:00
Markus Reiter
0d9217b45e
Merge pull request #4596 from reitermarkus/git-system_command
Use `system_command` for `GitDownloadStrategy`.
2018-08-03 14:58:15 +02:00
Markus Reiter
e220406a6e Use system_command for GitDownloadStrategy. 2018-08-03 11:17:09 +02:00
Markus Reiter
51fa194966 Move cached_location to #initialize. 2018-08-03 10:51:01 +02:00
Markus Reiter
528b4b367e Always chdir. 2018-08-03 10:50:49 +02:00
Markus Reiter
28fd59672a
Merge pull request #4543 from reitermarkus/verbose-system_command
Pass `verbose` to unpack strategies.
2018-08-03 10:47:51 +02:00
Markus Reiter
3a99e64646
Merge pull request #4593 from reitermarkus/curl-options
Merge `curl` options used by casks into download strategies.
2018-08-02 15:58:22 +02:00
Markus Reiter
81939dc496 Pass verbose to unpack strategies. 2018-08-02 15:52:55 +02:00
Markus Reiter
64bb92d95d Use URI.encode_www_form instead of CGI.escape. 2018-08-02 15:41:44 +02:00
Markus Reiter
7f4ea02047 Merge curl options used by casks into download strategies. 2018-08-02 11:18:46 +02:00
Markus Reiter
7c496f7a7e Explicitly pass specs to download strategy. 2018-08-02 10:33:14 +02:00
Markus Reiter
e367e7eea8 Explicitly pass url and mirrors to download strategy. 2018-08-02 10:09:35 +02:00
Markus Reiter
efd743a50d
Merge pull request #4585 from reitermarkus/refactor-download-strategies
Refactor download strategies.
2018-08-02 07:16:27 +02:00