s3_meta_sync 0.1.1 → 0.1.2

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: 37a24cec2c4aebc13b052d615ef89e90680f2382
4
- data.tar.gz: 27acabc2a3fa0a110dad04c1567c78fc37d7ed07
3
+ metadata.gz: 2e0d479fa242abc69a677504e15d1e3907da0d40
4
+ data.tar.gz: 351802613cb38c566476317eaa4cbcff2ce5f936
5
5
  SHA512:
6
- metadata.gz: 003a7fe86ed7329f5352540790edb64168bbe6fe7e6d51e6e4539ee8238744c4fd3e9bfa6e96aa81fe7c23a8b4d762ed94595453c2860930c9cd36a5ddaeccde
7
- data.tar.gz: 2b6d7b57bb944b4ad31316a400323223ee7a32d86df96d622b3bb0d14f941e90618399d8ade1d9faa6ea87f931b4828070a2a67ce03eb1054d51a590ab64c462
6
+ metadata.gz: 25283e6b0bb280cd37cf24050322b4802b407f7587ab982b0890b00680c0e1ac4d0137d44f353e3f5f1cc46aa363fb1c2ef47a58f11bdeebae0e44517cba36fd
7
+ data.tar.gz: 96cf366f80bb9340350a8147d158ab9969fa6e734e8d32a694526eeae54b64c65b033dbe3eefb0b6440a59bc4a62e56a7b4e639d44c94a02e5cec9431c5af70b
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/s3_meta_sync.rb CHANGED
@@ -4,6 +4,7 @@ require "yaml"
4
4
  require "digest/md5"
5
5
  require "aws/s3"
6
6
  require "optparse"
7
+ require "parallel"
7
8
 
8
9
  module S3MetaSync
9
10
  RemoteWithoutMeta = Class.new(Exception)
@@ -37,7 +38,7 @@ module S3MetaSync
37
38
  generate_meta(source)
38
39
  local_info = read_meta(source)
39
40
 
40
- in_multiple_threads(local_info) do |path, md5|
41
+ in_multiple_processes(local_info) do |path, md5|
41
42
  next if remote_info[path] == md5
42
43
  upload_file(source, path, destination)
43
44
  end
@@ -105,7 +106,7 @@ module S3MetaSync
105
106
  generate_meta(destination)
106
107
  local_info = read_meta(destination) # TODO maybe generate !?
107
108
 
108
- in_multiple_threads(remote_info) do |path, md5|
109
+ in_multiple_processes(remote_info) do |path, md5|
109
110
  next if local_info[path] == md5
110
111
  download_file(source, path, destination)
111
112
  end
@@ -123,16 +124,9 @@ module S3MetaSync
123
124
  @config[:region] unless @config[:region].to_s.empty?
124
125
  end
125
126
 
126
- def in_multiple_threads(data, &block)
127
- threads = [@config[:parallel] || 10, data.size].min
128
- data = data.to_a
129
- (1..threads).to_a.map do
130
- Thread.new do
131
- while chunk = data.pop
132
- yield chunk
133
- end
134
- end
135
- end.map(&:join)
127
+ def in_multiple_processes(data, &block)
128
+ processes = [@config[:parallel] || 10, data.size].min
129
+ Parallel.each(data, :in_processes => processes, &block) # we tried threads but that blew up with weird errors when having lot's of uploads :/
136
130
  end
137
131
  end
138
132
 
@@ -161,7 +155,7 @@ module S3MetaSync
161
155
  opts.on("-k", "--key KEY", "AWS access key") { |c| options[:key] = c }
162
156
  opts.on("-s", "--secret SECRET", "AWS secret key") { |c| options[:secret] = c }
163
157
  opts.on("-r", "--region REGION", "AWS region if not us-standard") { |c| options[:region] = c }
164
- opts.on("-p", "--parallel COUNT", Integer, "Use COUNT threads for download/upload default: 10") { |c| options[:parallel] = c }
158
+ opts.on("-p", "--parallel COUNT", Integer, "Use COUNT processes for download/upload default: 10") { |c| options[:parallel] = c }
165
159
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
166
160
  opts.on("-v", "--version", "Show Version"){ puts VERSION; exit}
167
161
  end.parse!(argv)
@@ -1,3 +1,3 @@
1
1
  module S3MetaSync
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -45,6 +45,20 @@ 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'
48
62
  description:
49
63
  email: michael@grosser.it
50
64
  executables:
metadata.gz.sig CHANGED
Binary file