s3_meta_sync 0.11.0 → 0.12.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 +4 -4
- data/lib/s3_meta_sync.rb +2 -0
- data/lib/s3_meta_sync/syncer.rb +9 -1
- data/lib/s3_meta_sync/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09f0ddb82b6163f8a53ff0ba9912bbd8225c3553'
|
4
|
+
data.tar.gz: 7e3062e0a16d5f1c76166bfdacd86621a4b0c48f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44432cf00d405f9ddaf94ea3376d0b8024237a43ce8fc0f97ad18c04e42ffe5387649dbecf22fd925625d42c9b477dd92aefe5c300872af91843fffb46dcc606
|
7
|
+
data.tar.gz: 8865b2d1ec3214bbcf3ac7e409aeaf7114b91d2a338eb40c3b10e06c96f0261fb159e6e84c34be582f39299911ed92cd93ff97b8f7bf526092027c8848c6ace5
|
data/lib/s3_meta_sync.rb
CHANGED
@@ -39,6 +39,8 @@ module S3MetaSync
|
|
39
39
|
opts.on("-s", "--secret SECRET", "AWS secret key") { |c| options[:secret] = c }
|
40
40
|
opts.on("-r", "--region REGION", "AWS region if not us-standard") { |c| options[:region] = c }
|
41
41
|
opts.on("-p", "--parallel COUNT", Integer, "Use COUNT threads for download/upload default: 10") { |c| options[:parallel] = c }
|
42
|
+
opts.on("-o", "--open-timeout TIMEOUT", Integer, "Net::HTTP open timeout in seconds default: 5") { |c| options[:open_timeout] = c }
|
43
|
+
opts.on("-t", "--read-timeout TIMEOUT", Integer, "Net::HTTP read timeout in seconds default: 10") { |c| options[:read_timeout] = c }
|
42
44
|
opts.on("--ssl-none", "Do not verify ssl certs") { options[:ssl_none] = true }
|
43
45
|
opts.on("-z", "--zip", "Zip when uploading to save bandwidth") { options[:zip] = true }
|
44
46
|
opts.on("--no-local-changes", "Do not md5 all the local files, they did not change") { options[:no_local_changes] = true }
|
data/lib/s3_meta_sync/syncer.rb
CHANGED
@@ -81,8 +81,10 @@ module S3MetaSync
|
|
81
81
|
store_meta(staging_area, remote_meta)
|
82
82
|
|
83
83
|
verify_integrity!(staging_area, destination, download, remote_meta[:files])
|
84
|
+
log "Swapping in directories #{destination} and #{staging_area}"
|
84
85
|
self.class.swap_in_directory(destination, staging_area)
|
85
86
|
FileUtils.mkdir(staging_area) # mktmpdir tries to remove this directory
|
87
|
+
log "Download finished"
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
@@ -129,6 +131,7 @@ module S3MetaSync
|
|
129
131
|
end
|
130
132
|
|
131
133
|
def verify_integrity!(staging_area, destination, changed, remote)
|
134
|
+
log "Verifying integrity of #{changed.size} files" if changed.size > 0
|
132
135
|
local = md5_hash(staging_area, changed)
|
133
136
|
corrupted = local.select { |file, md5| remote[file] != md5 }.map(&:first)
|
134
137
|
return if corrupted.empty?
|
@@ -180,6 +183,7 @@ module S3MetaSync
|
|
180
183
|
end
|
181
184
|
|
182
185
|
def delete_local_files(local, paths)
|
186
|
+
log "Delete #{paths.size} local files" if paths.size > 0
|
183
187
|
paths = paths.map { |path| "#{local}/#{path}" }
|
184
188
|
paths.each { |path| log "Deleting #{path}" }
|
185
189
|
FileUtils.rm_f(paths)
|
@@ -198,6 +202,7 @@ module S3MetaSync
|
|
198
202
|
end
|
199
203
|
|
200
204
|
def store_meta(source, meta)
|
205
|
+
log "Storing meta file"
|
201
206
|
file = "#{source}/#{META_FILE}"
|
202
207
|
FileUtils.mkdir_p(File.dirname(file))
|
203
208
|
File.write(file, meta.to_yaml)
|
@@ -262,12 +267,14 @@ module S3MetaSync
|
|
262
267
|
"https://s3#{"-#{region}" if region}.amazonaws.com/#{@bucket}/#{path}"
|
263
268
|
end
|
264
269
|
options = (@config[:ssl_none] ? {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE} : {})
|
270
|
+
options[:open_timeout] = @config.fetch(:open_timeout, 5) # 5 seconds
|
271
|
+
options[:read_timeout] = @config.fetch(:read_timeout, 10) # 10 seconds
|
265
272
|
retry_downloads(url: url) { open(url, options) }
|
266
273
|
end
|
267
274
|
|
268
275
|
def retry_downloads(url:)
|
269
276
|
yield
|
270
|
-
rescue OpenURI::HTTPError, Errno::ECONNRESET => e
|
277
|
+
rescue OpenURI::HTTPError, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::OpenTimeout, Net::ReadTimeout => e
|
271
278
|
max_retries = @config[:max_retries] || 2
|
272
279
|
http_error_retries ||= 0
|
273
280
|
http_error_retries += 1
|
@@ -290,6 +297,7 @@ module S3MetaSync
|
|
290
297
|
end
|
291
298
|
|
292
299
|
def delete_empty_folders(destination)
|
300
|
+
log "Deleting empty folders"
|
293
301
|
`find #{destination} -depth -empty -delete`
|
294
302
|
end
|
295
303
|
|
data/lib/s3_meta_sync/version.rb
CHANGED
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
|
+
version: 0.12.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: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|