saviour 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/lib/saviour.rb +2 -1
- data/lib/saviour/life_cycle.rb +13 -27
- data/lib/saviour/version.rb +1 -1
- data/saviour.gemspec +1 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43509e7e421eab9a8b45159d62c58513dbcb894b0ccecbd96a70cc0a29db74a6
|
4
|
+
data.tar.gz: 91b2eb4cf47dbac1b642c5ccc198ae0040ea0e81ef993c580e894065f1e58ecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4a1fb654e3290d827236f115ebfd93e2f6d4994e57d022dd473f41436365de36182e689d20526cea2c9bb113dd6b558901da5deda945f526242ab2e78e7c633
|
7
|
+
data.tar.gz: 8f3f81305ceb56195d67eb2a6700a5f05bb3e4567c892a983fe845689c952864497e2bd29c47a4256a88a6f003527855952d2ed78e6edc7cff80d66adacca7b0
|
data/.travis.yml
CHANGED
data/lib/saviour.rb
CHANGED
data/lib/saviour/life_cycle.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Saviour
|
2
2
|
class LifeCycle
|
3
|
+
SHOULD_USE_INTERLOCK = defined?(Rails)
|
4
|
+
|
3
5
|
class FileCreator
|
4
6
|
def initialize(current_path, file, column, connection)
|
5
7
|
@file = file
|
@@ -84,26 +86,19 @@ module Saviour
|
|
84
86
|
|
85
87
|
def delete!
|
86
88
|
DbHelpers.run_after_commit do
|
87
|
-
pool = Concurrent::
|
89
|
+
pool = Concurrent::Throttle.new Saviour::Config.concurrent_workers
|
88
90
|
|
89
91
|
futures = attached_files.map do |column|
|
90
|
-
|
91
|
-
file = @model.send(column)
|
92
|
+
pool.future(@model.send(column)) do |file|
|
92
93
|
path = file.persisted_path
|
93
94
|
file.uploader.storage.delete(path) if path
|
94
95
|
file.delete
|
95
|
-
|
96
|
+
end
|
96
97
|
end
|
97
98
|
|
98
99
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
99
|
-
futures.each
|
100
|
-
future.value
|
101
|
-
raise(future.reason) if future.rejected?
|
102
|
-
end
|
100
|
+
futures.each(&:value!)
|
103
101
|
end
|
104
|
-
|
105
|
-
pool.shutdown
|
106
|
-
pool.wait_for_termination
|
107
102
|
end
|
108
103
|
end
|
109
104
|
|
@@ -131,35 +126,26 @@ module Saviour
|
|
131
126
|
)
|
132
127
|
end.compact
|
133
128
|
|
134
|
-
pool = Concurrent::
|
129
|
+
pool = Concurrent::Throttle.new Saviour::Config.concurrent_workers
|
135
130
|
|
136
131
|
futures = uploaders.map { |uploader|
|
137
|
-
|
138
|
-
if
|
139
|
-
Rails.application.executor.wrap {
|
132
|
+
pool.future(uploader) { |given_uploader|
|
133
|
+
if SHOULD_USE_INTERLOCK
|
134
|
+
Rails.application.executor.wrap { given_uploader.upload }
|
140
135
|
else
|
141
|
-
|
136
|
+
given_uploader.upload
|
142
137
|
end
|
143
138
|
}
|
144
139
|
}
|
145
140
|
|
146
|
-
work = -> {
|
147
|
-
futures.map do |x|
|
148
|
-
x.value.tap do
|
149
|
-
raise(x.reason) if x.rejected?
|
150
|
-
end
|
151
|
-
end.compact
|
152
|
-
}
|
141
|
+
work = -> { futures.map(&:value!).compact }
|
153
142
|
|
154
|
-
result = if
|
143
|
+
result = if SHOULD_USE_INTERLOCK
|
155
144
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads(&work)
|
156
145
|
else
|
157
146
|
work.call
|
158
147
|
end
|
159
148
|
|
160
|
-
pool.shutdown
|
161
|
-
pool.wait_for_termination
|
162
|
-
|
163
149
|
attrs = result.to_h
|
164
150
|
|
165
151
|
uploaders.map(&:uploader).select { |x| x.class.after_upload_hooks.any? }.each do |uploader|
|
data/lib/saviour/version.rb
CHANGED
data/saviour.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.add_dependency "activerecord", ">= 5.1"
|
19
19
|
spec.add_dependency "activesupport", ">= 5.1"
|
20
20
|
spec.add_dependency "concurrent-ruby", ">= 1.0.5"
|
21
|
+
spec.add_dependency "concurrent-ruby-edge", ">= 0.6.0"
|
21
22
|
|
22
23
|
spec.add_development_dependency "bundler"
|
23
24
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saviour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.5
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: concurrent-ruby-edge
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.6.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.6.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -241,8 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
255
|
- !ruby/object:Gem::Version
|
242
256
|
version: '0'
|
243
257
|
requirements: []
|
244
|
-
|
245
|
-
rubygems_version: 2.7.6
|
258
|
+
rubygems_version: 3.0.3
|
246
259
|
signing_key:
|
247
260
|
specification_version: 4
|
248
261
|
summary: File storage handler following active record model lifecycle
|