s3cp 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,4 +1,7 @@
1
- === 0.2.7 / (Pending)
1
+ === 0.2.7 / 2012-03-09
2
+
3
+ * Fixed #3: s3cp adds extra slash when copying to the root of a bucket.
4
+ e.g. s3://myBucket//someFile or s3://myBucket//someFolderToCopy/someFile
2
5
 
3
6
  === 0.2.6 / 2012-03-06
4
7
 
data/lib/s3cp/s3cp.rb CHANGED
@@ -138,6 +138,12 @@ end
138
138
  destination = ARGV.last
139
139
  sources = ARGV[0..-2]
140
140
 
141
+ if options[:debug]
142
+ puts "sources: #{sources.inspect}"
143
+ puts "destination: #{destination}"
144
+ puts "Options: \n#{options.inspect}"
145
+ end
146
+
141
147
  class Proxy
142
148
  instance_methods.each { |m| undef_method m unless m =~ /(^__|^send$|^object_id$)/ }
143
149
 
@@ -157,18 +163,10 @@ def s3?(url)
157
163
  S3CP.bucket_and_key(url)[0]
158
164
  end
159
165
 
160
- if options[:debug]
161
- puts "URL: #{url}"
162
- puts "Options: \n#{options.inspect}"
163
- end
164
-
165
166
  if options[:verbose]
166
167
  @verbose = true
167
168
  end
168
169
 
169
- @bucket = $1
170
- @prefix = $2
171
-
172
170
  @includes = options[:include_regex].map { |s| Regexp.new(s) }
173
171
  @excludes = options[:exclude_regex].map { |s| Regexp.new(s) }
174
172
 
@@ -419,6 +417,14 @@ def s3_checksum(bucket, key)
419
417
  md5
420
418
  end
421
419
 
420
+ def key_path(prefix, key)
421
+ if (prefix.nil? || prefix.strip == '')
422
+ key
423
+ else
424
+ no_slash(prefix) + '/' + key
425
+ end
426
+ end
427
+
422
428
  def s3_size(bucket, key)
423
429
  metadata = @s3.interface.head(bucket, key)
424
430
  metadata["content-length"].to_i
@@ -437,7 +443,7 @@ def copy(from, to, options)
437
443
  end
438
444
  keys.each do |key|
439
445
  if match(key)
440
- dest = no_slash(key_to) + '/' + relative(key_from, key)
446
+ dest = key_path key_to, relative(key_from, key)
441
447
  s3_to_s3(bucket_from, key, bucket_to, dest) unless !options[:overwrite] && s3_exist?(bucket_to, dest)
442
448
  end
443
449
  end
@@ -449,7 +455,10 @@ def copy(from, to, options)
449
455
  files = Dir[from + "/**/*"]
450
456
  files.each do |f|
451
457
  if File.file?(f) && match(f)
452
- key = no_slash(key_to) + '/' + relative(from, f)
458
+ puts "bucket_to #{bucket_to}"
459
+ puts "no_slash(key_to) #{no_slash(key_to)}"
460
+ puts "relative(from, f) #{relative(from, f)}"
461
+ key = key_path key_to, relative(from, f)
453
462
  local_to_s3(bucket_to, key, File.expand_path(f), options) unless !options[:overwrite] && s3_exist?(bucket_to, key)
454
463
  end
455
464
  end
data/lib/s3cp/version.rb CHANGED
@@ -16,5 +16,5 @@
16
16
  # the License.
17
17
 
18
18
  module S3CP
19
- VERSION = "0.2.6"
19
+ VERSION = "0.2.7"
20
20
  end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 6
10
- version: 0.2.6
9
+ - 7
10
+ version: 0.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Boisvert
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-06 00:00:00 Z
18
+ date: 2012-03-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false