s3_meta_sync 0.7.0 → 0.8.1

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: 73d24caf55aefff70f928dca2019bbfbfe47bc97
4
- data.tar.gz: 2d57f5a45398c0cb7032d2a0747b1ffd38a7c18e
3
+ metadata.gz: c7a6e80c1fb50514a2c9b8d3ae92d5b64e36ea04
4
+ data.tar.gz: c981a2e2d8f5e66f71ee137fc5fcdd0447536ef0
5
5
  SHA512:
6
- metadata.gz: f6bcbe512d940706406c791c0dde947b172672cee1d6a4f361e08bc366ad9255e640b5f1bfc97aac4bb6af33f9fee56956a9125cb9c35751f81f82b74d5b69e5
7
- data.tar.gz: 359edb56cd2f2bef162f87089ca3fdcf979737ba495bd93ebc79d9aa785d2c23065307eb1add3b879d0cb64aff3851781336fef6845219372e6b999b21646be3
6
+ metadata.gz: f509c31ef5ed0f1ddb956b7b3d7ae8c4e714df69e69502b6f422a5095d4c494b25c128aba169c63dabab33af944504c4f84573bd79012cf0adc7ec7cfe2772f3
7
+ data.tar.gz: 2e60e1c6f3b49400c21b4cc25f210f2eec9a7aa1a87f00effdeb0d290bbf1674697b2b2cb46f6a6b2d8a236893800c117221cc966b01c2e928455407154002fa
@@ -201,7 +201,7 @@ module S3MetaSync
201
201
  end
202
202
 
203
203
  def download_meta(destination)
204
- content = download_content("#{destination}/#{META_FILE}")
204
+ content = download_content("#{destination}/#{META_FILE}") { |io| io.read }
205
205
  parse_yaml_content(content)
206
206
  rescue OpenURI::HTTPError
207
207
  retries ||= 1
@@ -220,18 +220,21 @@ module S3MetaSync
220
220
  end
221
221
 
222
222
  def download_file(source, path, destination, zip)
223
- content = download_content("#{source}/#{path}")
224
- content = Zip.unzip(content) if zip
225
- file = "#{destination}/#{path}"
226
- FileUtils.mkdir_p(File.dirname(file))
227
- File.write(file, content, :encoding => content.encoding)
223
+ download = download_content("#{source}/#{path}") # warning: using block form consumes more ram
224
+ download = Zip.unzip(download) if zip
225
+ path = "#{destination}/#{path}"
226
+ FileUtils.mkdir_p(File.dirname(path))
227
+
228
+ # consumes less ram then File.write(path, content), possibly also faster
229
+ File.open(path, 'wb') { |f| IO.copy_stream(download, f) }
230
+ download.close
228
231
  end
229
232
 
230
233
  def download_content(path)
231
234
  log "Downloading #{path}"
232
235
  url = "https://s3#{"-#{region}" if region}.amazonaws.com/#{@bucket}/#{path}"
233
236
  options = (@config[:ssl_none] ? {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE} : {})
234
- open(url, options).read
237
+ open(url, options)
235
238
  rescue OpenURI::HTTPError
236
239
  $!.message << " -- while trying to download #{url}"
237
240
  raise
@@ -1,3 +1,3 @@
1
1
  module S3MetaSync
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -12,8 +12,8 @@ module S3MetaSync
12
12
  io.string
13
13
  end
14
14
 
15
- def unzip(string)
16
- Zlib::GzipReader.new(StringIO.new(string, "rb")).read
15
+ def unzip(io)
16
+ Zlib::GzipReader.new(io)
17
17
  end
18
18
  end
19
19
  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.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core