s3sync 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/s3sync/cli.rb +27 -34
- data/lib/s3sync/config.rb +4 -5
- data/lib/s3sync/sync.rb +28 -4
- data/lib/s3sync/version.rb +1 -1
- metadata +21 -59
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8737f906e6e83042d2edb667c33705fe96f24bbd
|
4
|
+
data.tar.gz: c0d333e0b488014eb6e2273933019ba0ec58c9fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d94b3ec845ed9e48966045120a8c2292e5df64852c71d50eb3f0dec8d32e46d31082d8fd2380c7225aa856b98673cd20a02e119f2396aeaed5e6b5eb35490196
|
7
|
+
data.tar.gz: 3d22969a836de20ad4326ad5a134b3a221fa26a573ea4e0424186f6effb69ad63c7800f40fb49fecfc6ab616d306de489d54fd9c88b0edaf0c91042e6c413f12
|
data/lib/s3sync/cli.rb
CHANGED
@@ -63,6 +63,32 @@ module S3Sync
|
|
63
63
|
u.join ''
|
64
64
|
end
|
65
65
|
|
66
|
+
def execute(args)
|
67
|
+
# Connecting to amazon
|
68
|
+
s3 = AWS::S3.new
|
69
|
+
|
70
|
+
# From the command line
|
71
|
+
key, file = args
|
72
|
+
|
73
|
+
# Parsing the bucket name
|
74
|
+
bucket = nil
|
75
|
+
bucket, key = key.split(':') if key
|
76
|
+
|
77
|
+
# Running our custom method inside of the command class, taking care
|
78
|
+
# of the common errors here, saving duplications in each command;
|
79
|
+
begin
|
80
|
+
run s3, bucket, key, file, args
|
81
|
+
rescue AWS::S3::Errors::AccessDenied
|
82
|
+
raise FailureFeedback.new("Access Denied")
|
83
|
+
rescue AWS::S3::Errors::NoSuchBucket
|
84
|
+
raise FailureFeedback.new("There's no bucket named `#{bucket}'")
|
85
|
+
rescue AWS::S3::Errors::NoSuchKey
|
86
|
+
raise FailureFeedback.new("There's no key named `#{key}' in the bucket `#{bucket}'")
|
87
|
+
rescue AWS::S3::Errors::Base => exc
|
88
|
+
raise FailureFeedback.new("Error: `#{exc.message}'")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
66
92
|
protected
|
67
93
|
|
68
94
|
def parse_acl(opt)
|
@@ -432,40 +458,7 @@ END
|
|
432
458
|
cmd.add_command CmdParse::HelpCommand.new
|
433
459
|
cmd.add_command CmdParse::VersionCommand.new
|
434
460
|
|
435
|
-
#
|
436
|
-
# arguments needed to run the instance of the chosen command.
|
437
|
-
CmdParse::Command.class_eval do
|
438
|
-
define_method :execute, lambda { |args|
|
439
|
-
|
440
|
-
# Connecting to amazon
|
441
|
-
s3 = AWS::S3.new(
|
442
|
-
:access_key_id => conf[:AWS_ACCESS_KEY_ID],
|
443
|
-
:secret_access_key => conf[:AWS_SECRET_ACCESS_KEY],
|
444
|
-
)
|
445
|
-
|
446
|
-
# From the command line
|
447
|
-
key, file = args
|
448
|
-
|
449
|
-
# Parsing the bucket name
|
450
|
-
bucket = nil
|
451
|
-
bucket, key = key.split(':') if key
|
452
|
-
|
453
|
-
# Running our custom method inside of the command class, taking care
|
454
|
-
# of the common errors here, saving duplications in each command;
|
455
|
-
begin
|
456
|
-
run s3, bucket, key, file, args
|
457
|
-
rescue AWS::S3::Errors::AccessDenied
|
458
|
-
raise FailureFeedback.new("Access Denied")
|
459
|
-
rescue AWS::S3::Errors::NoSuchBucket
|
460
|
-
raise FailureFeedback.new("There's no bucket named `#{bucket}'")
|
461
|
-
rescue AWS::S3::Errors::NoSuchKey
|
462
|
-
raise FailureFeedback.new("There's no key named `#{key}' in the bucket `#{bucket}'")
|
463
|
-
rescue AWS::S3::Errors::Base => exc
|
464
|
-
raise FailureFeedback.new("Error: `#{exc.message}'")
|
465
|
-
end
|
466
|
-
}
|
467
|
-
end
|
468
|
-
|
461
|
+
# Boom! Execute it
|
469
462
|
cmd.parse
|
470
463
|
end
|
471
464
|
|
data/lib/s3sync/config.rb
CHANGED
@@ -63,7 +63,7 @@ module S3Sync
|
|
63
63
|
if File.exists? path
|
64
64
|
config = YAML.load_file path
|
65
65
|
config.each_pair do |key, value|
|
66
|
-
self[key.upcase.
|
66
|
+
self[key.upcase.to_s] = value
|
67
67
|
end
|
68
68
|
return
|
69
69
|
end
|
@@ -83,13 +83,12 @@ module S3Sync
|
|
83
83
|
paths_checked = read_from_file
|
84
84
|
read_from_env
|
85
85
|
|
86
|
+
# Update the environment with the latest values
|
87
|
+
ENV.update(self.to_hash)
|
88
|
+
|
86
89
|
# Checking which variables we have
|
87
90
|
not_found = []
|
88
91
|
|
89
|
-
REQUIRED_VARS.each {|v|
|
90
|
-
not_found << v if self[v].nil?
|
91
|
-
}
|
92
|
-
|
93
92
|
# Cleaning possibly empty env var from CONFIG_PATH
|
94
93
|
paths = (paths_checked || CONFIG_PATHS).select {|e| !e.empty?}
|
95
94
|
raise NoConfigFound.new(not_found, paths) if not_found.count > 0
|
data/lib/s3sync/sync.rb
CHANGED
@@ -111,6 +111,16 @@ module S3Sync
|
|
111
111
|
|
112
112
|
def list_files
|
113
113
|
nodes = {}
|
114
|
+
|
115
|
+
# Create the directory if it does not exist
|
116
|
+
if not File.exists?(@source)
|
117
|
+
FileUtils.mkdir_p(@source)
|
118
|
+
return nodes
|
119
|
+
end
|
120
|
+
|
121
|
+
# The path declared in `@source` exists, yay! Now we need read
|
122
|
+
# the whole directory and add all the readable files to the
|
123
|
+
# `nodes` hash.
|
114
124
|
Find.find(@source) do |file|
|
115
125
|
begin
|
116
126
|
st = File.stat file # Might fail
|
@@ -331,6 +341,7 @@ module S3Sync
|
|
331
341
|
end
|
332
342
|
|
333
343
|
def download_files destination, source, list
|
344
|
+
puts list
|
334
345
|
list.each {|e|
|
335
346
|
path = File.join destination.path, e.path
|
336
347
|
|
@@ -344,10 +355,23 @@ module S3Sync
|
|
344
355
|
# Making sure this new file will have a safe shelter
|
345
356
|
FileUtils.mkdir_p File.dirname(path)
|
346
357
|
|
347
|
-
#
|
348
|
-
|
349
|
-
|
350
|
-
|
358
|
+
# in some cases the s3 object will have a trailing '/' indicating
|
359
|
+
# a folder (this behavior noticed when the s3 folder is
|
360
|
+
# created by Transmit)
|
361
|
+
if path[-1] == '/'
|
362
|
+
FileUtils.mkdir_p path
|
363
|
+
else
|
364
|
+
# Downloading and saving the files
|
365
|
+
File.open(path, 'wb') do |file|
|
366
|
+
begin
|
367
|
+
obj.read do |chunk|
|
368
|
+
file.write chunk
|
369
|
+
end
|
370
|
+
rescue AWS::Core::Http::NetHttpHandler::TruncatedBodyError => e
|
371
|
+
$stderr.puts "WARNING: (retryable) TruncatedBodyError occured, retrying in a second #{file.basename}"
|
372
|
+
sleep 1
|
373
|
+
retry
|
374
|
+
end
|
351
375
|
end
|
352
376
|
end
|
353
377
|
end
|
data/lib/s3sync/version.rb
CHANGED
metadata
CHANGED
@@ -1,142 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Lincoln de Sousa
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-22 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: aws-sdk
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: cmdparse
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: debugger
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
38
|
+
- - ">="
|
60
39
|
- !ruby/object:Gem::Version
|
61
40
|
version: '0'
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: simplecov
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- -
|
45
|
+
- - ">="
|
68
46
|
- !ruby/object:Gem::Version
|
69
47
|
version: '0'
|
70
48
|
type: :development
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- -
|
52
|
+
- - ">="
|
76
53
|
- !ruby/object:Gem::Version
|
77
54
|
version: '0'
|
78
55
|
- !ruby/object:Gem::Dependency
|
79
56
|
name: rspec
|
80
57
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
58
|
requirements:
|
83
|
-
- -
|
59
|
+
- - ">="
|
84
60
|
- !ruby/object:Gem::Version
|
85
61
|
version: '0'
|
86
62
|
type: :development
|
87
63
|
prerelease: false
|
88
64
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
65
|
requirements:
|
91
|
-
- -
|
66
|
+
- - ">="
|
92
67
|
- !ruby/object:Gem::Version
|
93
68
|
version: '0'
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
70
|
name: bundler
|
96
71
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
72
|
requirements:
|
99
|
-
- - ~>
|
73
|
+
- - "~>"
|
100
74
|
- !ruby/object:Gem::Version
|
101
75
|
version: '1.3'
|
102
76
|
type: :development
|
103
77
|
prerelease: false
|
104
78
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
79
|
requirements:
|
107
|
-
- - ~>
|
80
|
+
- - "~>"
|
108
81
|
- !ruby/object:Gem::Version
|
109
82
|
version: '1.3'
|
110
83
|
- !ruby/object:Gem::Dependency
|
111
84
|
name: rake
|
112
85
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
86
|
requirements:
|
115
|
-
- -
|
87
|
+
- - ">="
|
116
88
|
- !ruby/object:Gem::Version
|
117
89
|
version: '0'
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
93
|
requirements:
|
123
|
-
- -
|
94
|
+
- - ">="
|
124
95
|
- !ruby/object:Gem::Version
|
125
96
|
version: '0'
|
126
97
|
- !ruby/object:Gem::Dependency
|
127
98
|
name: bump
|
128
99
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
100
|
requirements:
|
131
|
-
- -
|
101
|
+
- - ">="
|
132
102
|
- !ruby/object:Gem::Version
|
133
103
|
version: '0'
|
134
104
|
type: :development
|
135
105
|
prerelease: false
|
136
106
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
107
|
requirements:
|
139
|
-
- -
|
108
|
+
- - ">="
|
140
109
|
- !ruby/object:Gem::Version
|
141
110
|
version: '0'
|
142
111
|
description: Tool belt for managing your S3 buckets
|
@@ -158,33 +127,26 @@ files:
|
|
158
127
|
homepage: https://github.com/clarete/s3sync
|
159
128
|
licenses:
|
160
129
|
- MIT
|
130
|
+
metadata: {}
|
161
131
|
post_install_message:
|
162
132
|
rdoc_options: []
|
163
133
|
require_paths:
|
164
134
|
- lib
|
165
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
-
none: false
|
167
136
|
requirements:
|
168
|
-
- -
|
137
|
+
- - ">="
|
169
138
|
- !ruby/object:Gem::Version
|
170
139
|
version: '0'
|
171
|
-
segments:
|
172
|
-
- 0
|
173
|
-
hash: -1067117693450592295
|
174
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
141
|
requirements:
|
177
|
-
- -
|
142
|
+
- - ">="
|
178
143
|
- !ruby/object:Gem::Version
|
179
144
|
version: '0'
|
180
|
-
segments:
|
181
|
-
- 0
|
182
|
-
hash: -1067117693450592295
|
183
145
|
requirements: []
|
184
146
|
rubyforge_project:
|
185
|
-
rubygems_version:
|
147
|
+
rubygems_version: 2.2.0
|
186
148
|
signing_key:
|
187
|
-
specification_version:
|
149
|
+
specification_version: 4
|
188
150
|
summary: s3sync is a library that aggregates a good range of features for managing
|
189
151
|
your Amazon S3 buckets. It also provides basic interactive client
|
190
152
|
test_files: []
|