s3_meta_sync 0.4.6 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2539d4b1046c0137ed0312b606f8e6fce06badd
4
- data.tar.gz: adcdfdbcd6fb0668b6757501d66d17d968f7ec5a
3
+ metadata.gz: 76bef3c6abd828c51f0d655a70cb20ddc105eda9
4
+ data.tar.gz: 031cf9ab48d0a25d92c2bbca7dad0a26ed33f83a
5
5
  SHA512:
6
- metadata.gz: 52634d1a5f489dd89ab0af3fb57f64bdaa58c7c1fdad7ab77bbd704ee10e4cf09d93e63541c8b1a195e0693f71189423059de337f07f0ef49cc4521b9fe28616
7
- data.tar.gz: d48b10f892ddecfb47d3c003ed51a04ce8cdd88481947781e8e65437999e06bb160d533f9a8f400c1d9707453011a4065447dca84ee9e7c5d6bdc1f791394213
6
+ metadata.gz: 6bb3dd0b41a96d4792a3d352d30f02c43e37383a9222e820c7b5a6ca8cbd915db5a5009bfb5fac2d1cbc70f64324e1b57516af896ddad48948ac348ecb505b9c
7
+ data.tar.gz: b814848c48971212b05c08fb50f5232c0bb661ba1a31640c5b38d13b4b439c49514ec1e8b5037678edcf6e1bd64d25fdfc3c8d75ba988b0829010e6ac6c39259
@@ -17,6 +17,8 @@ require "s3_meta_sync/zip"
17
17
 
18
18
  module S3MetaSync
19
19
  class Syncer
20
+ DEFAULT_REGION = 'us-east-1'
21
+
20
22
  def initialize(config)
21
23
  @config = config
22
24
  end
@@ -67,7 +69,7 @@ module S3MetaSync
67
69
 
68
70
  log "Downloading: #{download.size} Deleting: #{delete.size}", true
69
71
 
70
- unless download.empty? && delete.empty?
72
+ if download.any? || delete.any?
71
73
  Dir.mktmpdir do |staging_area|
72
74
  FileUtils.mkdir_p(destination)
73
75
  copy_content(destination, staging_area)
@@ -148,7 +150,7 @@ module S3MetaSync
148
150
  def delete_local_files(local, paths)
149
151
  paths = paths.map { |path| "#{local}/#{path}" }
150
152
  paths.each { |path| log "Deleting #{path}" }
151
- File.delete(*paths)
153
+ FileUtils.rm_f(paths)
152
154
  end
153
155
 
154
156
  def s3
@@ -185,17 +187,21 @@ module S3MetaSync
185
187
 
186
188
  def read_meta(source)
187
189
  file = "#{source}/#{META_FILE}"
188
- YAML.load(File.read(file)) if File.exist?(file)
190
+ parse_yaml_content(File.read(file)) if File.exist?(file)
189
191
  end
190
192
 
191
193
  def download_meta(destination)
192
194
  content = download_content("#{destination}/#{META_FILE}")
193
- result = YAML.load(content)
194
- result.key?(:files) ? result : {files: result} # support new an old format
195
+ parse_yaml_content(content)
195
196
  rescue
196
197
  raise RemoteWithoutMeta
197
198
  end
198
199
 
200
+ def parse_yaml_content(content)
201
+ result = YAML.load(content)
202
+ result.key?(:files) ? result : {files: result} # support new and old format
203
+ end
204
+
199
205
  def download_file(source, path, destination, zip)
200
206
  content = download_content("#{source}/#{path}")
201
207
  content = Zip.unzip(content) if zip
@@ -237,7 +243,8 @@ module S3MetaSync
237
243
  end
238
244
 
239
245
  def region
240
- @config[:region] unless @config[:region].to_s.empty?
246
+ region = @config[:region]
247
+ region if region != DEFAULT_REGION
241
248
  end
242
249
 
243
250
  def in_multiple_threads(data)
@@ -1,3 +1,3 @@
1
1
  module S3MetaSync
2
- VERSION = "0.4.6"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_meta_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-v1