s3cp 1.1.3 → 1.1.4

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.
@@ -1,4 +1,11 @@
1
- === 1.1.3 (Pending)
1
+ === 1.1.4 (2012-09-11)
2
+
3
+ * Fixed: Command-line completion that was broken since 1.1.0 (after aws-sdk migration)
4
+
5
+ * Fixed: s3-to-s3 copy that was broken since 1.1.0 (after aws-sdk migration)
6
+
7
+
8
+ === 1.1.3 (2012-09-05)
2
9
 
3
10
  * Fixed: s3-to-s3 copy command failed with error message:
4
11
  `s3_to_s3': undefined local variable or method `s3_' for #<Object:0x7f333b239298> (NameError)
@@ -15,15 +15,8 @@
15
15
  # License for the specific language governing permissions and limitations under
16
16
  # the License.
17
17
 
18
- require 'rubygems'
19
- require 'extensions/kernel' if RUBY_VERSION =~ /1.8/
20
- require 'right_aws'
21
- require 'optparse'
22
- require 'date'
23
- require 'highline/import'
24
- require 'tempfile'
25
-
26
18
  require 's3cp/utils'
19
+ require 'tempfile'
27
20
 
28
21
  cmd_line = ENV['COMP_LINE']
29
22
  position = ENV['COMP_POINT'].to_i
@@ -115,13 +108,11 @@ if (prefix && prefix.length > 0) || (url =~ /s3\:\/\/[^\/]+\//) || (url =~ /\:$/
115
108
 
116
109
  # try directory first
117
110
  dir_options = Hash.new
118
- dir_options[:prefix] = prefix
119
111
  dir_options[:delimiter] = delimiter
120
112
  begin
121
- @s3.interface.incrementally_list_bucket(bucket, dir_options) do |page|
122
- entries = page[:common_prefixes]
123
- entries << page[:contents][0][:key] if page[:contents].length > 0 && entries.length > 0
124
- result = entries
113
+ result = []
114
+ @s3.buckets[bucket_from].objects.with_prefix(prefix).as_tree(:delimier => options[:delimiter], :append => false).children.each do |entry|
115
+ result << entry.key
125
116
  end
126
117
  rescue => e
127
118
  debug "exception #{e}"
@@ -137,22 +128,18 @@ if (prefix && prefix.length > 0) || (url =~ /s3\:\/\/[^\/]+\//) || (url =~ /\:$/
137
128
  # there may be longer matches
138
129
  if (result.size == 0) || (result.size == 1)
139
130
  prefix = result[0] if result.size == 1
140
- file_options = Hash.new
141
- file_options[:prefix] = prefix
142
- file_options["max-keys"] = 100
131
+ s3_options = Hash.new
132
+ s3_options[:limit] = 1000
143
133
  short_keys = Hash.new
144
134
  all_keys = []
145
135
  begin
146
- @s3.interface.incrementally_list_bucket(bucket, file_options) do |page|
147
- entries = page[:contents]
148
- entries.each do |entry|
149
- key = entry[:key]
150
- pos = prefix.length-1
151
- pos += 1 while pos+1 < key.length && key[pos+1].chr == delimiter
152
- short_key = key[0..pos]
153
- short_keys[short_key] = key
154
- all_keys << key
155
- end
136
+ @s3.buckets[bucket].objects.with_prefix(prefix).each(s3_options) do |entry|
137
+ key = entry.key
138
+ pos = prefix.length-1
139
+ pos += 1 while pos+1 < key.length && key[pos+1].chr == delimiter
140
+ short_key = key[0..pos]
141
+ short_keys[short_key] = key
142
+ all_keys << key
156
143
  end
157
144
  rescue => e
158
145
  debug "exception #{e}"
@@ -173,8 +160,7 @@ else
173
160
  # complete bucket name
174
161
  bucket ||= url
175
162
  begin
176
- buckets = @s3.interface.list_all_my_buckets()
177
- bucket_names = buckets.map { |b| b[:name] }
163
+ bucket_names = @s3.buckets.to_a.map(&:name)
178
164
  matching = bucket_names.select { |b| b =~ /^#{bucket}/ }
179
165
  print_buckets(matching)
180
166
  rescue => e
@@ -458,8 +458,8 @@ def copy(from, to, options)
458
458
  when :s3_to_s3
459
459
  if options[:recursive]
460
460
  keys = []
461
- @s3.interface.incrementally_list_bucket(bucket_from, :prefix => key_from) do |page|
462
- page[:contents].each { |entry| keys << entry[:key] }
461
+ @s3.buckets[bucket_from].objects.with_prefix(key_from).each do |entry|
462
+ keys << entry.key
463
463
  end
464
464
  keys.each do |key|
465
465
  if match(key)
@@ -488,8 +488,8 @@ def copy(from, to, options)
488
488
  when :s3_to_local
489
489
  if options[:recursive]
490
490
  keys = []
491
- @s3.interface.incrementally_list_bucket(bucket_from, :prefix => key_from) do |page|
492
- page[:contents].each { |entry| keys << entry[:key] }
491
+ @s3.buckets[bucket_from].objects.with_prefix(key_from).each do |entry|
492
+ keys << entry.key
493
493
  end
494
494
  keys.each do |key|
495
495
  if match(key)
@@ -16,5 +16,5 @@
16
16
  # the License.
17
17
 
18
18
  module S3CP
19
- VERSION = "1.1.3"
19
+ VERSION = "1.1.4"
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: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 3
10
- version: 1.1.3
9
+ - 4
10
+ version: 1.1.4
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-09-05 00:00:00 Z
18
+ date: 2012-09-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  prerelease: false