fog 0.2.25 → 0.2.26
Sign up to get free protection for your applications and to get access to all the features.
- data/fog.gemspec +1 -1
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/s3/files.rb +1 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +19 -14
- data/spec/aws/models/s3/files_spec.rb +23 -1
- metadata +2 -2
data/fog.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.2.
|
10
|
+
s.version = '0.2.26'
|
11
11
|
s.date = '2010-08-18'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
data/lib/fog.rb
CHANGED
@@ -61,23 +61,28 @@ module Fog
|
|
61
61
|
end
|
62
62
|
response = Excon::Response.new
|
63
63
|
if bucket = @data[:buckets][bucket_name]
|
64
|
+
contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
|
65
|
+
(options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
|
66
|
+
(options['marker'] && object['Key'] <= options['marker'])
|
67
|
+
end.map do |object|
|
68
|
+
data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)}
|
69
|
+
data.merge!({
|
70
|
+
'LastModified' => Time.parse(data['LastModified']),
|
71
|
+
'Owner' => bucket['Owner'],
|
72
|
+
'Size' => data['Size'].to_i
|
73
|
+
})
|
74
|
+
data
|
75
|
+
end
|
76
|
+
max_keys = options['max-keys'] || 1000
|
77
|
+
size = [max_keys, 1000].min
|
78
|
+
truncated_contents = contents[0...size]
|
79
|
+
|
64
80
|
response.status = 200
|
65
81
|
response.body = {
|
66
|
-
'Contents'
|
67
|
-
|
68
|
-
(options['marker'] && object['Key'] <= options['marker'])
|
69
|
-
end.map do |object|
|
70
|
-
data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)}
|
71
|
-
data.merge!({
|
72
|
-
'LastModified' => Time.parse(data['LastModified']),
|
73
|
-
'Owner' => bucket['Owner'],
|
74
|
-
'Size' => data['Size'].to_i
|
75
|
-
})
|
76
|
-
data
|
77
|
-
end,
|
78
|
-
'IsTruncated' => false,
|
82
|
+
'Contents' => truncated_contents,
|
83
|
+
'IsTruncated' => truncated_contents.size != contents.size,
|
79
84
|
'Marker' => options['marker'],
|
80
|
-
'MaxKeys' =>
|
85
|
+
'MaxKeys' => max_keys,
|
81
86
|
'Name' => bucket['Name'],
|
82
87
|
'Prefix' => options['prefix']
|
83
88
|
}
|
@@ -3,10 +3,13 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|
3
3
|
describe 'Fog::AWS::S3::Files' do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
@directory = AWS[:s3].directories.create(:key =>
|
6
|
+
@directory = AWS[:s3].directories.create(:key => "fog#{Time.now.to_f}")
|
7
7
|
end
|
8
8
|
|
9
9
|
after(:each) do
|
10
|
+
until @directory.files.reload.empty?
|
11
|
+
@directory.files.each {|file| file.destroy}
|
12
|
+
end
|
10
13
|
@directory.destroy
|
11
14
|
end
|
12
15
|
|
@@ -34,6 +37,25 @@ describe 'Fog::AWS::S3::Files' do
|
|
34
37
|
directory.files.all.should be_nil
|
35
38
|
end
|
36
39
|
|
40
|
+
it "should return 1000 files and report truncated" do
|
41
|
+
1010.times do |n|
|
42
|
+
@directory.files.create(:key => "file-#{n}")
|
43
|
+
end
|
44
|
+
response = @directory.files.all
|
45
|
+
response.should have(1000).items
|
46
|
+
response.is_truncated.should be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should limit the max_keys to 1000" do
|
50
|
+
1010.times do |n|
|
51
|
+
@directory.files.create(:key => "file-#{n}")
|
52
|
+
end
|
53
|
+
response = @directory.files.all(:max_keys => 2000)
|
54
|
+
response.should have(1000).items
|
55
|
+
response.max_keys.should == 2000
|
56
|
+
response.is_truncated.should be_true
|
57
|
+
end
|
58
|
+
|
37
59
|
end
|
38
60
|
|
39
61
|
describe "#create" do
|