etna 0.1.38 → 0.1.39

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: e7c665ee736c06bf1b566467985638cd41a5b3536f848fe2971174aab26ba3a4
4
- data.tar.gz: 22bd58b6dd1a4902ee91f6588f53cf56a4bec9db5b42d9236ed9cd7c4310a2f0
3
+ metadata.gz: c21212f38bbad3cf757eb84a9e453428c9d0b6f195fd34eb81f98aeff2746490
4
+ data.tar.gz: 3581821244c087cbbfbac162f9a5c61911e06ab64923c603a144d36ca3bedff0
5
5
  SHA512:
6
- metadata.gz: 04ad878b6f9593a06b65b7652ba3b6da9b0a2aa4de57981ef91247b19eb606e5018cc01e45d033ccdaf5b755cb92149e92a1d26218c47fce6c1a77085dce300e
7
- data.tar.gz: 26134c1553f33e59e13f5ec737bd11b0bd8e62e1f54c3b1c5963560d1078cb00d5ce0255c01bddae86dc19f9bb38ae5a0dfc6b9d2845e955e55df0299ad1f456
6
+ metadata.gz: 3289530a2e874d2b79b0da66ea787e30b335b7a60626e4b67f1be9919067d4b79752db4e878ca8851dbce6c68a1e59a573bcbc60314bb7a35268cd37cc2eeaae
7
+ data.tar.gz: 2758348f253992e08fbf589d2b5444844becf69e179872c630804a7e8885568189168edd056c56beabe4ed5dc3e0905f46c51595896bd7bdd1255fbe4ece71ec
@@ -228,14 +228,44 @@ module Etna
228
228
  end
229
229
 
230
230
  folder_contents.files.all.each do |file|
231
- rename_file(Etna::Clients::Metis::RenameFileRequest.new(
232
- bucket_name: source_bucket,
231
+ # If file exists in destination, delete the older file.
232
+ list_dest_folder_request = Etna::Clients::Metis::ListFolderRequest.new(
233
+ bucket_name: dest_bucket,
233
234
  project_name: project_name,
234
- file_path: file.file_path,
235
- new_bucket_name: dest_bucket,
236
- new_file_path: file.file_path,
237
- create_parent: true)
235
+ folder_path: ::File.dirname(file.file_path)
238
236
  )
237
+
238
+ dest_file = list_folder(list_dest_folder_request).files.all.find { |f| f.file_name == file.file_name }
239
+
240
+ should_rename = true
241
+ if (dest_file && file.updated_at <= dest_file.updated_at)
242
+ # Delete source file if it's out of date
243
+ delete_file(Etna::Clients::Metis::DeleteFileRequest.new(
244
+ bucket_name: source_bucket,
245
+ project_name: project_name,
246
+ file_path: file.file_path,
247
+ ))
248
+
249
+ should_rename = false
250
+ elsif (dest_file && file.updated_at > dest_file.updated_at)
251
+ # Delete dest file if it's out of date
252
+ delete_file(Etna::Clients::Metis::DeleteFileRequest.new(
253
+ bucket_name: dest_bucket,
254
+ project_name: project_name,
255
+ file_path: dest_file.file_path,
256
+ ))
257
+ end
258
+
259
+ if should_rename
260
+ rename_file(Etna::Clients::Metis::RenameFileRequest.new(
261
+ bucket_name: source_bucket,
262
+ project_name: project_name,
263
+ file_path: file.file_path,
264
+ new_bucket_name: dest_bucket,
265
+ new_file_path: file.file_path,
266
+ create_parent: true)
267
+ )
268
+ end
239
269
  end
240
270
 
241
271
  # 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.38
4
+ version: 0.1.39
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-21 00:00:00.000000000 Z
11
+ date: 2021-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack