remote_files 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/remote_files/configuration.rb +38 -9
- data/lib/remote_files/file.rb +2 -2
- data/lib/remote_files/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '039a33d2003b7da6a18815b1663c5078b0f3e8bd439469282e8e629fad8cc934'
|
4
|
+
data.tar.gz: c113130c97455d7b7698a4cf34d00e1501552f64c4ca1355d193e67990034740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d257ec5e612c589907606a393b532c7c075037f64ab939f380a5159767ad6e9c25473c8e9fad184274fa828d7ceac0023087abc9e345253a8b0192f82b8d2c26
|
7
|
+
data.tar.gz: 78038598723c23add49fe33b64a8dc939695d61c3fbd0189ed32f5f66bdfbfff8b4c2fdb74bbba1eb0fae084b2bc6f950ac2111c0609bf0b935518769900d90e
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'concurrent-ruby'
|
2
|
+
|
1
3
|
module RemoteFiles
|
2
4
|
class Configuration
|
3
5
|
attr_reader :name
|
@@ -6,6 +8,7 @@ module RemoteFiles
|
|
6
8
|
@name = name
|
7
9
|
@stores = []
|
8
10
|
@stores_map = {}
|
11
|
+
@max_delete_in_parallel = config.delete(:max_delete_in_parallel) || 10
|
9
12
|
from_hash(config)
|
10
13
|
end
|
11
14
|
|
@@ -125,27 +128,53 @@ module RemoteFiles
|
|
125
128
|
RemoteFiles.delete_file(file)
|
126
129
|
end
|
127
130
|
|
128
|
-
def delete_now!(file)
|
131
|
+
def delete_now!(file, parallel: false)
|
129
132
|
exceptions = []
|
130
133
|
stores = file.read_write_stores
|
131
134
|
|
132
135
|
raise "No stores configured" if stores.empty?
|
133
136
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
137
|
+
if parallel
|
138
|
+
delete_in_parallel!(file, stores, exceptions)
|
139
|
+
else
|
140
|
+
stores.each do |store|
|
141
|
+
begin
|
142
|
+
store.delete!(file.identifier)
|
143
|
+
rescue NotFoundError => e
|
144
|
+
exceptions << e
|
145
|
+
end
|
139
146
|
end
|
140
147
|
end
|
141
148
|
|
142
|
-
if exceptions.size == stores.size # they all failed
|
143
|
-
raise exceptions.first
|
144
|
-
end
|
149
|
+
raise exceptions.first if exceptions.size == stores.size # they all failed
|
145
150
|
|
146
151
|
true
|
147
152
|
end
|
148
153
|
|
154
|
+
# This method is used to delete a file from all stores in parallel
|
155
|
+
# exceptions are passed back to the caller
|
156
|
+
def delete_in_parallel!(file, stores, exceptions)
|
157
|
+
pool = Concurrent::FixedThreadPool.new(@max_delete_in_parallel)
|
158
|
+
|
159
|
+
futures = stores.map do |store|
|
160
|
+
Concurrent::Promises.future_on(pool) do
|
161
|
+
begin
|
162
|
+
store.delete!(file.identifier)
|
163
|
+
rescue NotFoundError => e
|
164
|
+
e
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
futures.each do |future|
|
170
|
+
result = future.value
|
171
|
+
exceptions << result if result.is_a?(Exception)
|
172
|
+
end
|
173
|
+
|
174
|
+
pool.shutdown
|
175
|
+
pool.wait_for_termination
|
176
|
+
end
|
177
|
+
|
149
178
|
def synchronize!(file)
|
150
179
|
file.missing_stores.each do |store|
|
151
180
|
next if store.read_only?
|
data/lib/remote_files/file.rb
CHANGED
data/lib/remote_files/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_files
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-aws
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: concurrent-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.0
|
41
55
|
description: A library for uploading files to multiple remote storage backends like
|
42
56
|
Amazon S3 and Rackspace CloudFiles.
|
43
57
|
email:
|
@@ -76,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
90
|
- !ruby/object:Gem::Version
|
77
91
|
version: '0'
|
78
92
|
requirements: []
|
79
|
-
rubygems_version: 3.5.
|
93
|
+
rubygems_version: 3.5.16
|
80
94
|
signing_key:
|
81
95
|
specification_version: 4
|
82
96
|
summary: The purpose of the library is to implement a simple interface for uploading
|