activestorage-delayed 0.3.2 → 0.3.4

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: 28e99a88c820e43d1a17fb11ebdd37a116cb27bdccc1337c09854962b27d3a7b
4
- data.tar.gz: 99a2174762bd1f6aab22b204ed321a46f7f2b01478c07f22a48ff1e68ceba9f5
3
+ metadata.gz: d3378c0e2948f1f326f736c4ef7947dea58df8f4f6a0be0db293b8b12211f9aa
4
+ data.tar.gz: 309c3e54d9bf480a289bafe6bb22820cb25fb298610fde2b2171be45ee39340a
5
5
  SHA512:
6
- metadata.gz: 035413b7b1412f8ff6d230c96147e56d450c5c32c5ab1d69556a1b8bbbd095ba208eea0430bca146cb41ae831552cf0f6c6c6e848da85ba0e0059c5499b96b5b
7
- data.tar.gz: e9ab0587c96b020947e0224ae4fee5fac96ecca1fb99acaa417b476ad2ad91e09bb44a1d2b8cfaefbd2f12a87c148e22a4f509f8a3c45346fb65800d5b0b00b7
6
+ metadata.gz: d71f44517ca41a2ce2f093187ecced04afccbe864e1999223c310207c383a7980abb983339264a68c67966e48bff113c383ced0f4abc7ff1d25a68f1d5d32000
7
+ data.tar.gz: 85f7a2fad1f398c7354ba1d5c5b2f946d3b939af6ce0d1135c5e8ade4664df94a30e8148f8c5d2a9ce4d90f3e066558bdfdbfc18468b8612bbea7f8403ffa3e4
@@ -12,23 +12,10 @@
12
12
  </content>
13
13
  <orderEntry type="jdk" jdkName="Remote: ruby-3.1.1-p18" jdkType="RUBY_SDK" />
14
14
  <orderEntry type="sourceFolder" forTests="false" />
15
- <orderEntry type="library" scope="PROVIDED" name="actioncable (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="actionmailbox (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="actionmailer (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="actionpack (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="actiontext (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="actionview (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="activejob (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="activemodel (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="activerecord (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="activestorage (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
26
15
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
27
16
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
28
17
  <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, Remote: ruby-3.1.1-p18) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="byebug (v11.1.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
30
18
  <orderEntry type="library" scope="PROVIDED" name="capybara (v3.36.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, Remote: ruby-3.1.1-p18) [gem]" level="application" />
32
19
  <orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, Remote: ruby-3.1.1-p18) [gem]" level="application" />
33
20
  <orderEntry type="library" scope="PROVIDED" name="database_cleaner-active_record (v2.0.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
34
21
  <orderEntry type="library" scope="PROVIDED" name="database_cleaner-core (v2.0.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
@@ -37,7 +24,6 @@
37
24
  <orderEntry type="library" scope="PROVIDED" name="erubi (v1.10.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
38
25
  <orderEntry type="library" scope="PROVIDED" name="factory_bot_rails (v6.2.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
39
26
  <orderEntry type="library" scope="PROVIDED" name="globalid (v1.0.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
41
27
  <orderEntry type="library" scope="PROVIDED" name="mail (v2.7.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
42
28
  <orderEntry type="library" scope="PROVIDED" name="marcel (v1.0.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
43
29
  <orderEntry type="library" scope="PROVIDED" name="matrix (v0.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
@@ -48,13 +34,12 @@
48
34
  <orderEntry type="library" scope="PROVIDED" name="net-pop (v0.1.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
49
35
  <orderEntry type="library" scope="PROVIDED" name="net-smtp (v0.3.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
50
36
  <orderEntry type="library" scope="PROVIDED" name="nio4r (v2.5.8, Remote: ruby-3.1.1-p18) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
51
38
  <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
52
39
  <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
53
40
  <orderEntry type="library" scope="PROVIDED" name="rack-test (v1.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="rails (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
55
41
  <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
56
42
  <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.4.2, Remote: ruby-3.1.1-p18) [gem]" level="application" />
57
- <orderEntry type="library" scope="PROVIDED" name="railties (v7.0.2.3, Remote: ruby-3.1.1-p18) [gem]" level="application" />
58
43
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, Remote: ruby-3.1.1-p18) [gem]" level="application" />
59
44
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, Remote: ruby-3.1.1-p18) [gem]" level="application" />
60
45
  <orderEntry type="library" scope="PROVIDED" name="rbs (v2.1.0, Remote: ruby-3.1.1-p18) [gem]" level="application" />
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activestorage-delayed (0.2.0)
4
+ activestorage-delayed (0.3.3)
5
5
  activestorage
6
6
  rails
7
7
 
@@ -13,29 +13,31 @@ module ActivestorageDelayed
13
13
  return unless delayed_upload
14
14
 
15
15
  remove_files
16
- upload_photos
17
- save_changes
16
+ save_changes if upload_photos
18
17
  end
19
18
 
20
19
  private
21
20
 
22
21
  def upload_photos
23
- tmp_files_data.each(&method(:upload_photo))
22
+ tmp_files_data.map(&method(:upload_photo)).all?
24
23
  end
25
24
 
26
25
  def upload_photo(file_data)
27
26
  parse_file_io(file_data) do |io|
28
27
  file_data['io'] = io
28
+ remove_duplicated_object(file_data['key']) if file_data['key']
29
29
  model.send(attr_name).attach(file_data.transform_keys(&:to_sym))
30
30
  model.send("#{attr_name}_after_upload", file_data)
31
- rescue => e # rubocop:disable Style/RescueStandardError
32
- print_failure(e, file_data)
33
31
  end
32
+ true
33
+ rescue => e # rubocop:disable Style/RescueStandardError
34
+ print_failure(e, file_data) && false
34
35
  end
35
36
 
36
37
  def print_failure(error, file_data = {})
37
38
  details = "#{error.message}. #{error.backtrace[0..20]}"
38
- Rails.logger.error("***#{self.class.name} -> Failed uploading file (#{file_data['filename']}): #{details}")
39
+ key = "#{delayed_upload.id}-#{file_data['filename']}"
40
+ Rails.logger.error("***#{self.class.name} -> Failed uploading file (#{key}): #{details}")
39
41
  model.send("#{attr_name}_error_upload", error, file_data)
40
42
  end
41
43
 
@@ -71,9 +73,11 @@ module ActivestorageDelayed
71
73
  # @param io [StringIO, File]
72
74
  # @param variant_info [Hash, Nil] ActiveStorage variant info. Sample: { resize_to_fit: [400, 400], convert: 'jpg' }
73
75
  def transform_variation(io, variant_info, &block)
74
- return block.call(io) unless variant_info
76
+ variant_info ? ActiveStorage::Variation.wrap(variant_info).transform(io, &block) : block.call(io)
77
+ end
75
78
 
76
- ActiveStorage::Variation.wrap(variant_info).transform(io, &block)
79
+ def remove_duplicated_object(key)
80
+ ActiveStorage::Blob.where(key: key).take&.destroy!
77
81
  end
78
82
 
79
83
  def model
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivestorageDelayed
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage-delayed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owen Peredo Diaz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-22 00:00:00.000000000 Z
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage