miteru 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7b9163d8f3fc3beea8d97a85f26d08c83a9f649c3484511fc8a1a6e42e0d553
4
- data.tar.gz: b341ec7ece5359f0358853e48a8bdd84e51d3b0fd0fc1e8e484634bd4652b276
3
+ metadata.gz: 58464f5c1b0b17549201ea547edbcf22cd83bcbbd7ef1a1233ab2d04eeb4c13c
4
+ data.tar.gz: 6a8048507e00ded2fe11ef1a71b05536a267ee54b6e64b7662cf5f238ace84fd
5
5
  SHA512:
6
- metadata.gz: b532eaa3a58e0918695fb19a2ff56096ab80b98858466bd7efff53b28afe2aa57a9a70bf7f4043941e996be8b4afdd62119ab52ec61a363513f0612927f92bde
7
- data.tar.gz: 13fe4fb667d5c7f270508720f61ae579cbf3d08e3fbc8d7bdabb060a7421c008e727d99101bcd09b0a7d077c2f32355ea8a5fc017a6b3b5e14f098000850512f
6
+ metadata.gz: efb6fcb505fff1451ab5cbff5a0bbc1d3e480aa7cc4f51005b84065c5c174b4c12e9609f07217f7cbf0bdb844dd8efe7430e99e2f3bb7ea3fa7207d9ff531ae4
7
+ data.tar.gz: 5ab2d22a2c9c647665a3feefd9b579ac336e434a84320db6df4ba3b7e1ea4d44a14b1db7a91f8e63add7e7a0d544d0d791cd07f1d4258065642c2fae35c0002b
@@ -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
- hash = sha256(downloaded_as)
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
- if duplicated?(hash)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miteru
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki