etna 0.1.39 → 0.1.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/etna/application.rb +1 -1
- data/lib/etna/clients/metis/client.rb +52 -29
- 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: e83d3c30c23693011d59b103f8b5a9372950eba1b3123376a288826204d47c62
|
4
|
+
data.tar.gz: c3b50952e71d91f4361a87e872ba5532849644abe42fbc9e480549726a6bbf93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c561cdd7db4631c267f2edba8421b94baba5de790ca1ff9edd06cd21d039d7224d868eaa43ba7090b4114b595830ac777c1c4688ec15c9320cde90530be4e5
|
7
|
+
data.tar.gz: 7148582a82f7e90357ed6658c7337bce7b34dd532b4a899ac27a2d74f40f34224cb6c225b2aa4db4164c467aa8a5c189d7acf28a1c462097e619e9875fbdc4d1
|
data/lib/etna/application.rb
CHANGED
@@ -192,7 +192,7 @@ module Etna::Application
|
|
192
192
|
status = 'failed'
|
193
193
|
raise
|
194
194
|
ensure
|
195
|
-
if Yabeda.configured?
|
195
|
+
if defined?(Yabeda) && Yabeda.configured?
|
196
196
|
tags = { command: cmd.class.name, status: status, application: application }
|
197
197
|
dur = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
198
198
|
|
@@ -210,34 +210,30 @@ module Etna
|
|
210
210
|
}
|
211
211
|
end
|
212
212
|
|
213
|
-
def
|
214
|
-
|
215
|
-
Etna::Clients::Metis::ListFolderRequest.new(
|
216
|
-
project_name: project_name,
|
217
|
-
bucket_name: source_bucket,
|
218
|
-
folder_path: folder.folder_path
|
219
|
-
))
|
213
|
+
def resolve_conflicts_and_verify_rename(project_name:, source_bucket:, dest_bucket:, folder:, file:)
|
214
|
+
parent_folder = ::File.dirname(file.file_path)
|
220
215
|
|
221
|
-
|
222
|
-
recursively_rename_folder(
|
223
|
-
project_name: project_name,
|
224
|
-
source_bucket: source_bucket,
|
225
|
-
dest_bucket: dest_bucket,
|
226
|
-
folder: sub_folder
|
227
|
-
)
|
228
|
-
end
|
216
|
+
should_rename_original = true
|
229
217
|
|
230
|
-
|
218
|
+
# If the destination folder already exists, check to see if
|
219
|
+
# the file also exists, otherwise we risk a
|
220
|
+
# rename conflict.
|
221
|
+
create_folder_request = CreateFolderRequest.new(
|
222
|
+
project_name: project_name,
|
223
|
+
bucket_name: dest_bucket,
|
224
|
+
folder_path: parent_folder
|
225
|
+
)
|
226
|
+
|
227
|
+
if folder_exists?(create_folder_request)
|
231
228
|
# If file exists in destination, delete the older file.
|
232
229
|
list_dest_folder_request = Etna::Clients::Metis::ListFolderRequest.new(
|
233
230
|
bucket_name: dest_bucket,
|
234
231
|
project_name: project_name,
|
235
|
-
folder_path:
|
232
|
+
folder_path: parent_folder
|
236
233
|
)
|
237
234
|
|
238
235
|
dest_file = list_folder(list_dest_folder_request).files.all.find { |f| f.file_name == file.file_name }
|
239
236
|
|
240
|
-
should_rename = true
|
241
237
|
if (dest_file && file.updated_at <= dest_file.updated_at)
|
242
238
|
# Delete source file if it's out of date
|
243
239
|
delete_file(Etna::Clients::Metis::DeleteFileRequest.new(
|
@@ -246,7 +242,7 @@ module Etna
|
|
246
242
|
file_path: file.file_path,
|
247
243
|
))
|
248
244
|
|
249
|
-
|
245
|
+
should_rename_original = false
|
250
246
|
elsif (dest_file && file.updated_at > dest_file.updated_at)
|
251
247
|
# Delete dest file if it's out of date
|
252
248
|
delete_file(Etna::Clients::Metis::DeleteFileRequest.new(
|
@@ -255,17 +251,44 @@ module Etna
|
|
255
251
|
file_path: dest_file.file_path,
|
256
252
|
))
|
257
253
|
end
|
254
|
+
end
|
258
255
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
256
|
+
should_rename_original
|
257
|
+
end
|
258
|
+
|
259
|
+
def recursively_rename_folder(project_name:, source_bucket:, dest_bucket:, folder:)
|
260
|
+
folder_contents = list_folder(
|
261
|
+
Etna::Clients::Metis::ListFolderRequest.new(
|
262
|
+
project_name: project_name,
|
263
|
+
bucket_name: source_bucket,
|
264
|
+
folder_path: folder.folder_path
|
265
|
+
))
|
266
|
+
|
267
|
+
folder_contents.folders.all.each do |sub_folder|
|
268
|
+
recursively_rename_folder(
|
269
|
+
project_name: project_name,
|
270
|
+
source_bucket: source_bucket,
|
271
|
+
dest_bucket: dest_bucket,
|
272
|
+
folder: sub_folder
|
273
|
+
)
|
274
|
+
end
|
275
|
+
|
276
|
+
folder_contents.files.all.each do |file|
|
277
|
+
should_rename = resolve_conflicts_and_verify_rename(
|
278
|
+
project_name: project_name,
|
279
|
+
source_bucket: source_bucket,
|
280
|
+
dest_bucket: dest_bucket,
|
281
|
+
folder: folder,
|
282
|
+
file: file)
|
283
|
+
|
284
|
+
rename_file(Etna::Clients::Metis::RenameFileRequest.new(
|
285
|
+
bucket_name: source_bucket,
|
286
|
+
project_name: project_name,
|
287
|
+
file_path: file.file_path,
|
288
|
+
new_bucket_name: dest_bucket,
|
289
|
+
new_file_path: file.file_path,
|
290
|
+
create_parent: true)
|
291
|
+
) if should_rename
|
269
292
|
end
|
270
293
|
|
271
294
|
# Now delete the source folder
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saurabh Asthana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|