remote_files 3.5.1 → 3.7.0.pre.alpha.1
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/fog_store.rb +1 -1
- 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: 00b8fe0548d27ed5c3e7f604be263e0c70f0b3fce867c6528886d45372122aa6
|
4
|
+
data.tar.gz: a3064a9ef511550b94a4965e55eb2f2b15b45dc2244965a1fedb8e7b5f8e45a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '068011e2c0d56dc7244fa15840d19751cadbefa0e940153f71c11c23b90877d0b6ed49721b79b281c2bb8cf3fcf807c4c78947be632e508f84e01ffe4b3123a0'
|
7
|
+
data.tar.gz: 9ef6af33362c317887fc25ba988bcfc58414306b83f085890b6041387bddda6c60bb11c917b79a2a6259417fbc54194764d74eceed36c0f62a0a8822b1285109
|
@@ -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
@@ -134,9 +134,9 @@ module RemoteFiles
|
|
134
134
|
:body => file.content,
|
135
135
|
:content_type => file.content_type,
|
136
136
|
:key => file.identifier,
|
137
|
-
:public => options[:public],
|
138
137
|
:encryption => options[:encryption]
|
139
138
|
}
|
139
|
+
store_options[:public] = options[:public] if options.key?(:public)
|
140
140
|
if file.options[:multipart_chunk_size]
|
141
141
|
raise RemoteFiles::Error.new("Only S3 supports the multipart_chunk_size option") unless options[:provider] == 'AWS'
|
142
142
|
chunk_size = file.options[:multipart_chunk_size]
|
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.pre.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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.
|
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
|