s3cp 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/bin/s3mv +4 -0
- data/lib/s3cp/s3cp.rb +14 -3
- data/lib/s3cp/version.rb +1 -1
- metadata +5 -3
data/History.txt
CHANGED
data/bin/s3mv
ADDED
data/lib/s3cp/s3cp.rb
CHANGED
@@ -40,6 +40,7 @@ options[:retry_backoff] = ENV["S3CP_BACKOFF"] ? ENV["S3CP_BACKOFF"].to_f :
|
|
40
40
|
options[:include_regex] = []
|
41
41
|
options[:exclude_regex] = []
|
42
42
|
options[:sync] = false
|
43
|
+
options[:move] = false
|
43
44
|
|
44
45
|
op = OptionParser.new do |opts|
|
45
46
|
opts.banner = <<-BANNER
|
@@ -76,6 +77,10 @@ op = OptionParser.new do |opts|
|
|
76
77
|
options[:sync] = true
|
77
78
|
end
|
78
79
|
|
80
|
+
opts.on("--move", "Move mode: delete original file(s) after copying.") do
|
81
|
+
options[:move] = true
|
82
|
+
end
|
83
|
+
|
79
84
|
opts.on("--max-attempts N", "Number of attempts to upload/download until checksum matches (default #{options[:retries]})") do |attempts|
|
80
85
|
options[:retries] = attempts.to_i
|
81
86
|
end
|
@@ -236,13 +241,14 @@ def md5(filename)
|
|
236
241
|
digest.hexdigest
|
237
242
|
end
|
238
243
|
|
239
|
-
def s3_to_s3(bucket_from, key, bucket_to, dest)
|
244
|
+
def s3_to_s3(bucket_from, key, bucket_to, dest, options = {})
|
240
245
|
log(with_headers("Copy s3://#{bucket_from}/#{key} to s3://#{bucket_to}/#{dest}"))
|
241
246
|
if @headers.empty?
|
242
247
|
@s3.interface.copy(bucket_from, key, bucket_to, dest)
|
243
248
|
else
|
244
249
|
@s3.interface.copy(bucket_from, key, bucket_to, dest, :copy, @headers)
|
245
250
|
end
|
251
|
+
@s3.interface.delete(bucket_from, key) if options[:move]
|
246
252
|
end
|
247
253
|
|
248
254
|
def local_to_s3(bucket_to, key, file, options = {})
|
@@ -327,6 +333,7 @@ def local_to_s3(bucket_to, key, file, options = {})
|
|
327
333
|
else
|
328
334
|
log "Already synchronized."
|
329
335
|
end
|
336
|
+
FileUtils.rm file if options[:move]
|
330
337
|
end
|
331
338
|
|
332
339
|
def s3_to_local(bucket_from, key_from, dest, options = {})
|
@@ -399,6 +406,8 @@ def s3_to_local(bucket_from, key_from, dest, options = {})
|
|
399
406
|
|
400
407
|
retries += 1
|
401
408
|
end until options[:checksum] == false || expected_md5.nil? || md5(dest) == expected_md5
|
409
|
+
|
410
|
+
@s3.interface.delete(bucket_from, key_from) if options[:move]
|
402
411
|
end
|
403
412
|
|
404
413
|
def s3_exist?(bucket, key)
|
@@ -452,11 +461,11 @@ def copy(from, to, options)
|
|
452
461
|
keys.each do |key|
|
453
462
|
if match(key)
|
454
463
|
dest = key_path key_to, relative(key_from, key)
|
455
|
-
s3_to_s3(bucket_from, key, bucket_to, dest) unless !options[:overwrite] && s3_exist?(bucket_to, dest)
|
464
|
+
s3_to_s3(bucket_from, key, bucket_to, dest, options) unless !options[:overwrite] && s3_exist?(bucket_to, dest)
|
456
465
|
end
|
457
466
|
end
|
458
467
|
else
|
459
|
-
s3_to_s3(bucket_from, key_from, bucket_to, key_to) unless !options[:overwrite] && s3_exist?(bucket_to, key_to)
|
468
|
+
s3_to_s3(bucket_from, key_from, bucket_to, key_to, options) unless !options[:overwrite] && s3_exist?(bucket_to, key_to)
|
460
469
|
end
|
461
470
|
when :local_to_s3
|
462
471
|
if options[:recursive]
|
@@ -500,8 +509,10 @@ def copy(from, to, options)
|
|
500
509
|
end
|
501
510
|
if options[:recursive]
|
502
511
|
FileUtils.cp_r from, to
|
512
|
+
FileUtils.rm_r from if options[:move]
|
503
513
|
else
|
504
514
|
FileUtils.cp from, to
|
515
|
+
FileUtils.rm from if options[:move]
|
505
516
|
end
|
506
517
|
end
|
507
518
|
end
|
data/lib/s3cp/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3cp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Boisvert
|
@@ -139,6 +139,7 @@ executables:
|
|
139
139
|
- s3du
|
140
140
|
- s3ls
|
141
141
|
- s3mod
|
142
|
+
- s3mv
|
142
143
|
- s3rm
|
143
144
|
- s3stat
|
144
145
|
- s3up
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- History.txt
|
163
164
|
- README.md
|
164
165
|
- bin/s3up
|
166
|
+
- bin/s3mv
|
165
167
|
- bin/s3rm
|
166
168
|
- bin/s3dir
|
167
169
|
- bin/s3mod
|