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 +4 -4
- data/.idea/activestorage-delayed.iml +1 -16
- data/Gemfile.lock +1 -1
- data/lib/activestorage-delayed/delayed_uploader.rb +12 -8
- data/lib/activestorage-delayed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3378c0e2948f1f326f736c4ef7947dea58df8f4f6a0be0db293b8b12211f9aa
|
4
|
+
data.tar.gz: 309c3e54d9bf480a289bafe6bb22820cb25fb298610fde2b2171be45ee39340a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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.
|
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
|
-
|
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
|
-
|
76
|
+
variant_info ? ActiveStorage::Variation.wrap(variant_info).transform(io, &block) : block.call(io)
|
77
|
+
end
|
75
78
|
|
76
|
-
|
79
|
+
def remove_duplicated_object(key)
|
80
|
+
ActiveStorage::Blob.where(key: key).take&.destroy!
|
77
81
|
end
|
78
82
|
|
79
83
|
def model
|
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.
|
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-
|
11
|
+
date: 2022-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activestorage
|