down 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/down.gemspec +1 -1
- data/lib/down.rb +6 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d8c92123cb9fa3a46484b51840f8363c74cdd6b
|
|
4
|
+
data.tar.gz: 05d06a93dbe891dfe90332acfb0dd06bfd98e6da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67f3abe4b028843b738d3e1e0cd4642664831dd3d4240a8cf0c7197b14bcbb8a5de0f1e9f982a90f651c82cb783ea09f83ac25a9713948d4d7f4f8ffc2b3ba3c
|
|
7
|
+
data.tar.gz: cc63303532e1e748a997051d1349335c63ebf5f56d9725ffafa04eea2b4f36679e4f29830c889f2f6c483eec96c805a44cf06932fbe1aa44d2ae0809d17fff4a
|
data/down.gemspec
CHANGED
data/lib/down.rb
CHANGED
|
@@ -20,7 +20,7 @@ module Down
|
|
|
20
20
|
content_length_proc = options.delete(:content_length_proc)
|
|
21
21
|
timeout = options.delete(:timeout)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
tries = max_redirects + 1
|
|
24
24
|
|
|
25
25
|
begin
|
|
26
26
|
uri = URI.parse(url)
|
|
@@ -41,9 +41,9 @@ module Down
|
|
|
41
41
|
read_timeout: timeout,
|
|
42
42
|
redirect: false,
|
|
43
43
|
}.merge(options))
|
|
44
|
-
rescue OpenURI::HTTPRedirect =>
|
|
45
|
-
url =
|
|
46
|
-
retry if (
|
|
44
|
+
rescue OpenURI::HTTPRedirect => redirect
|
|
45
|
+
url = redirect.uri.to_s
|
|
46
|
+
retry if (tries -= 1) > 0
|
|
47
47
|
raise Down::NotFound, "too many redirects"
|
|
48
48
|
rescue => error
|
|
49
49
|
raise if error.is_a?(Down::Error)
|
|
@@ -95,6 +95,8 @@ module Down
|
|
|
95
95
|
def copy_to_tempfile(basename, io)
|
|
96
96
|
tempfile = Tempfile.new(["down", File.extname(basename)], binmode: true)
|
|
97
97
|
if io.is_a?(OpenURI::Meta) && io.is_a?(Tempfile)
|
|
98
|
+
io.close
|
|
99
|
+
tempfile.close
|
|
98
100
|
FileUtils.mv io.path, tempfile.path
|
|
99
101
|
else
|
|
100
102
|
IO.copy_stream(io, tempfile)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: down
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.
|
|
4
|
+
version: 2.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janko Marohnić
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|