miteru 1.0.0 → 1.0.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/lib/miteru/downloader.rb +9 -8
- data/lib/miteru/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58464f5c1b0b17549201ea547edbcf22cd83bcbbd7ef1a1233ab2d04eeb4c13c
|
4
|
+
data.tar.gz: 6a8048507e00ded2fe11ef1a71b05536a267ee54b6e64b7662cf5f238ace84fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb6fcb505fff1451ab5cbff5a0bbc1d3e480aa7cc4f51005b84065c5c174b4c12e9609f07217f7cbf0bdb844dd8efe7430e99e2f3bb7ea3fa7207d9ff531ae4
|
7
|
+
data.tar.gz: 5ab2d22a2c9c647665a3feefd9b579ac336e434a84320db6df4ba3b7e1ea4d44a14b1db7a91f8e63add7e7a0d544d0d791cd07f1d4258065642c2fae35c0002b
|
data/lib/miteru/downloader.rb
CHANGED
@@ -22,12 +22,19 @@ module Miteru
|
|
22
22
|
|
23
23
|
def download_kit(kit)
|
24
24
|
destination = kit.filepath_to_download
|
25
|
+
|
25
26
|
begin
|
26
27
|
downloaded_as = HTTPClient.download(kit.url, destination)
|
27
|
-
|
28
|
+
rescue Down::Error => e
|
29
|
+
puts "Failed to download: #{kit.url} (#{e})"
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
hash = sha256(downloaded_as)
|
28
34
|
|
35
|
+
ActiveRecord::Base.connection_pool.with_connection do
|
29
36
|
# Remove a downloaded file if it is not unique
|
30
|
-
|
37
|
+
unless Record.unique_hash?(hash)
|
31
38
|
puts "Don't download #{kit.url}. The same hash is already recorded. (SHA256: #{hash})."
|
32
39
|
FileUtils.rm downloaded_as
|
33
40
|
return
|
@@ -36,8 +43,6 @@ module Miteru
|
|
36
43
|
# Record a kit in DB
|
37
44
|
Record.create_by_kit_and_hash(kit, hash)
|
38
45
|
puts "Download #{kit.url} as #{downloaded_as}"
|
39
|
-
rescue Down::Error => e
|
40
|
-
puts "Failed to download: #{kit.url} (#{e})"
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
@@ -49,9 +54,5 @@ module Miteru
|
|
49
54
|
memo[path] = hash
|
50
55
|
hash
|
51
56
|
end
|
52
|
-
|
53
|
-
def duplicated?(hash)
|
54
|
-
!Record.unique_hash?(hash)
|
55
|
-
end
|
56
57
|
end
|
57
58
|
end
|
data/lib/miteru/version.rb
CHANGED