activestorage-delayed 0.3.3 → 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/Gemfile.lock +1 -1
- data/lib/activestorage-delayed/delayed_uploader.rb +9 -6
- 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
|
data/Gemfile.lock
CHANGED
@@ -13,24 +13,25 @@ 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
31
|
end
|
32
|
+
true
|
32
33
|
rescue => e # rubocop:disable Style/RescueStandardError
|
33
|
-
print_failure(e, file_data)
|
34
|
+
print_failure(e, file_data) && false
|
34
35
|
end
|
35
36
|
|
36
37
|
def print_failure(error, file_data = {})
|
@@ -72,9 +73,11 @@ module ActivestorageDelayed
|
|
72
73
|
# @param io [StringIO, File]
|
73
74
|
# @param variant_info [Hash, Nil] ActiveStorage variant info. Sample: { resize_to_fit: [400, 400], convert: 'jpg' }
|
74
75
|
def transform_variation(io, variant_info, &block)
|
75
|
-
|
76
|
+
variant_info ? ActiveStorage::Variation.wrap(variant_info).transform(io, &block) : block.call(io)
|
77
|
+
end
|
76
78
|
|
77
|
-
|
79
|
+
def remove_duplicated_object(key)
|
80
|
+
ActiveStorage::Blob.where(key: key).take&.destroy!
|
78
81
|
end
|
79
82
|
|
80
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
|