20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/ruby-libstorj/ext/list_files_request.rb', line 20
def self.after_work_cb
args = [::LibStorj::Ext::UV::Work.by_ref, :int]
FFI::Function.new :void, args do |work_req_ptr|
req = self.new work_req_ptr[:data]
files, total_files, response = req.values_at %i[files total_files response]
error = ::LibStorj::Ext::Curl.curl_code_to_string req[:error_code]
c_handle = FFI::Function.new :void, %i[string pointer int], req[:handle]
catch :no_response_error do
begin
response_string = ::LibStorj::Ext::JsonC.stringify(response)
response_hash = JSON.parse(response_string)
unless response_hash.is_a?(Hash) && !response_hash['error'].nil?
throw :no_response_error
end
error = response_error if response_error && error.empty?
rescue JSON::ParserError => err
end
end
c_handle.call error, files, total_files
end
end
|