s3_meta_sync 0.1.7 → 0.2.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: d378c2048e347b69b8163925f00afe0be9fc81e1
4
- data.tar.gz: da855bf2005d23ec2b707f12193c208fee1a3054
3
+ metadata.gz: b85122789e5f9115e5e5feae13687496fe84afc6
4
+ data.tar.gz: 934425dbaa4f5555e418f6ccaade64144d888b99
5
5
  SHA512:
6
- metadata.gz: 9a75bf8dbb10772fd13b5eeac525a461a070a2416ee4e49ca608e70154ba33fc9a6aecc81c212d67f92f2b26e1c4dde0696ffdb06eff711d8f08973028d910ab
7
- data.tar.gz: 24254882c7a9db8bcfee7a5f9f452ee73dc7cda15f2ea5c99c36b175ec540e17f7d510ecd646c0231ddb5e5c25cbf4c65094bc8b60d59e89b5ce8005eb09b4d7
6
+ metadata.gz: 3ea26c334b2aceda1df5f55cf17e66c5cb1f3a5cfb2d5246a09059f6bfc9246f17b7eb24680f492a461a40ebb9b98644b5fdb40cccf027fdf3ef93544219e6d8
7
+ data.tar.gz: 1067bb5ff41eae7fed797b291bdeb936cb19bf7060bf4b7d36ea46ea5ef5994653c54d1715f8e764a7ba821e40aed7e05c1c22ea3e8c3d1c89fe1c5cba672558
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  module S3MetaSync
2
- VERSION = "0.1.7"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/s3_meta_sync.rb CHANGED
@@ -2,11 +2,15 @@ require "s3_meta_sync/version"
2
2
  require "open-uri"
3
3
  require "yaml"
4
4
  require "digest/md5"
5
- require "aws/s3"
6
5
  require "optparse"
7
- require "parallel"
8
6
  require "fileutils"
9
7
 
8
+ # need to require these or upload in multiple threads will fail on systems with high load
9
+ require "aws/s3"
10
+ require "aws/s3/s3_object"
11
+ require "aws/core/response"
12
+ require "aws/s3/object_collection"
13
+
10
14
  module S3MetaSync
11
15
  RemoteWithoutMeta = Class.new(Exception)
12
16
  META_FILE = ".s3-meta-sync"
@@ -124,20 +128,27 @@ module S3MetaSync
124
128
  end
125
129
 
126
130
  def download_files(source, destination, paths)
127
- in_parallel(:threads, paths) { |path| download_file(source, path, destination) }
131
+ in_multiple_threads(paths) { |path| download_file(source, path, destination) }
128
132
  end
129
133
 
130
134
  def upload_files(source, destination, paths)
131
- in_parallel(:processes, paths) { |path| upload_file(source, path, destination) }
135
+ in_multiple_threads(paths) { |path| upload_file(source, path, destination) }
132
136
  end
133
137
 
134
138
  def region
135
139
  @config[:region] unless @config[:region].to_s.empty?
136
140
  end
137
141
 
138
- def in_parallel(way, data, &block)
139
- processes = [@config[:parallel] || 10, data.size].min
140
- Parallel.each(data, :"in_#{way}" => processes, &block) # we tried threads but that blew up with weird errors when having lot's of uploads :/
142
+ def in_multiple_threads(data)
143
+ threads = [@config[:parallel] || 10, data.size].min
144
+ data = data.dup
145
+ threads.times do
146
+ Thread.new do
147
+ while slice = data.shift
148
+ yield slice
149
+ end
150
+ end
151
+ end
141
152
  end
142
153
 
143
154
  def log(text, important=false)
@@ -174,7 +185,7 @@ module S3MetaSync
174
185
  opts.on("-k", "--key KEY", "AWS access key") { |c| options[:key] = c }
175
186
  opts.on("-s", "--secret SECRET", "AWS secret key") { |c| options[:secret] = c }
176
187
  opts.on("-r", "--region REGION", "AWS region if not us-standard") { |c| options[:region] = c }
177
- opts.on("-p", "--parallel COUNT", Integer, "Use COUNT processes for download/upload default: 10") { |c| options[:parallel] = c }
188
+ opts.on("-p", "--parallel COUNT", Integer, "Use COUNT threads for download/upload default: 10") { |c| options[:parallel] = c }
178
189
  opts.on("-V", "--verbose", "Verbose mode"){ options[:verbose] = true }
179
190
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
180
191
  opts.on("-v", "--version", "Show Version"){ puts VERSION; exit}
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_meta_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -45,20 +45,6 @@ dependencies:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- - !ruby/object:Gem::Dependency
49
- name: parallel
50
- requirement: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
48
  description:
63
49
  email: michael@grosser.it
64
50
  executables:
metadata.gz.sig CHANGED
Binary file