File tree Expand file tree Collapse file tree 4 files changed +26
-8
lines changed
lib/fog/storage/google_json Expand file tree Collapse file tree 4 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,15 @@ def get(bucket_name, options = {})
21
21
:projection => projection
22
22
) . to_h
23
23
24
- new ( data )
24
+ directory = new ( data )
25
+ # Because fog-aws accepts these arguments on files at the
26
+ # directories.get level, we need to preload the directory files
27
+ # with these attributes here.
28
+ files_attr_names = %i( delimiter page_token max_results prefix )
29
+
30
+ file_opts = options . select { |k , _ | files_attr_names . include? k }
31
+ directory . files ( file_opts )
32
+ directory
25
33
rescue ::Google ::Apis ::ClientError => e
26
34
# metageneration check failures returns HTTP 412 Precondition Failed
27
35
raise e unless e . status_code == 404 || e . status_code == 412
Original file line number Diff line number Diff line change @@ -37,11 +37,10 @@ def destroy
37
37
false
38
38
end
39
39
40
- def files
40
+ def files ( attr = { } )
41
41
@files ||= begin
42
42
Fog ::Storage ::GoogleJSON ::Files . new (
43
- :directory => self ,
44
- :service => service
43
+ attr . merge ( :directory => self , :service => service )
45
44
)
46
45
end
47
46
end
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ class Files < Fog::Collection
16
16
17
17
def all ( options = { } )
18
18
requires :directory
19
-
20
- data = service . list_objects ( directory . key , options ) . to_h [ :items ] || [ ]
19
+ data = service . list_objects ( directory . key , attributes . merge ( options ) )
20
+ . to_h [ :items ] || [ ]
21
21
load ( data )
22
22
end
23
23
Original file line number Diff line number Diff line change @@ -20,8 +20,19 @@ class Real
20
20
# object as distinct results (defaults to False)
21
21
# @return [Google::Apis::StorageV1::Objects]
22
22
def list_objects ( bucket , options = { } )
23
- request_options = ::Google ::Apis ::RequestOptions . default . merge ( options )
24
- @storage_json . list_objects ( bucket , :options => request_options )
23
+ allowed_opts = %i(
24
+ delimiter
25
+ max_results
26
+ page_token
27
+ prefix
28
+ projection
29
+ versions
30
+ )
31
+
32
+ @storage_json . list_objects (
33
+ bucket ,
34
+ options . select { |k , _ | allowed_opts . include? k }
35
+ )
25
36
end
26
37
end
27
38
You can’t perform that action at this time.
0 commit comments