s3_meta_sync 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/s3_meta_sync/version.rb +1 -1
- data/lib/s3_meta_sync.rb +19 -8
- data.tar.gz.sig +0 -0
- metadata +1 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85122789e5f9115e5e5feae13687496fe84afc6
|
4
|
+
data.tar.gz: 934425dbaa4f5555e418f6ccaade64144d888b99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ea26c334b2aceda1df5f55cf17e66c5cb1f3a5cfb2d5246a09059f6bfc9246f17b7eb24680f492a461a40ebb9b98644b5fdb40cccf027fdf3ef93544219e6d8
|
7
|
+
data.tar.gz: 1067bb5ff41eae7fed797b291bdeb936cb19bf7060bf4b7d36ea46ea5ef5994653c54d1715f8e764a7ba821e40aed7e05c1c22ea3e8c3d1c89fe1c5cba672558
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/s3_meta_sync/version.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
139
|
-
|
140
|
-
|
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
|
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.
|
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
|