better_record 0.15.0 → 0.15.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f547a8cc802463bac755a8c63cd0a56a29820e4dff4e1fca44aaca4522113f63
|
4
|
+
data.tar.gz: 4c491bc39f6047d0c4abeb6b4a92df97facbdea967d634b9b1f912fd36cb6a79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b47c26116fc3921a517895e13f0f2fb9d2110829fbb08c50214a79e084ce3a710f844e5a5b582faf1d0eb63a654e05c2557081224040a1a5547f94515788cad3
|
7
|
+
data.tar.gz: 2140d13ad729a20cd2545d0884d4ecfad9cd9c2e20a921f66314050d5a87183dabd5293feb36a1dda5ec5464cfeaf11b4bf0c218a14ed194c3c6e39242236c72
|
@@ -3,20 +3,31 @@ module BetterRecord
|
|
3
3
|
queue_as :default
|
4
4
|
|
5
5
|
def perform(**params)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
begin
|
7
|
+
if record = params[:model].constantize.find_by(params[:query].deep_symbolize_keys)
|
8
|
+
blob = record.__send__(params[:attachment].to_sym).blob
|
9
|
+
tmp = Tempfile.new
|
10
|
+
tmp.binmode
|
11
|
+
tmp.write(blob.service.download(blob.variant(params[:options]).processed.key))
|
12
|
+
tmp.flush
|
13
|
+
tmp.rewind
|
14
|
+
record.__send__(params[:attachment]).attach(
|
15
|
+
io: tmp,
|
16
|
+
filename: blob.filename,
|
17
|
+
content_type: blob.content_type
|
18
|
+
)
|
19
|
+
begin
|
20
|
+
blob.purge_later
|
21
|
+
rescue
|
22
|
+
end
|
23
|
+
params[:backup_action].present? && record.__send__(params[:backup_action].to_sym)
|
24
|
+
end
|
25
|
+
true
|
26
|
+
rescue
|
27
|
+
p $!.to_s
|
28
|
+
p $!.message
|
29
|
+
p $!.backtrace.first(25)
|
30
|
+
return false
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
@@ -68,8 +68,8 @@ module BetterRecord
|
|
68
68
|
__send__ (shrink_later ? :perform_later : :perform_now), {
|
69
69
|
model: self.class.to_s,
|
70
70
|
query: {id: self.id},
|
71
|
-
attachment: avatar_name,
|
72
|
-
backup_action:
|
71
|
+
attachment: avatar_name.to_s,
|
72
|
+
backup_action: "cache_current_#{avatar_name}",
|
73
73
|
options: shrink_large_image
|
74
74
|
}
|
75
75
|
rescue
|