列表文件:后端错误(无错误代码)Google Drive SDK

时间:2013-01-30 16:48:14

标签: google-drive-api

我们已经构建了一个网络应用程序,可根据用户定义的业务规则自动将电子邮件附件直接索引并保存到Google云端硬盘。我们在同步某些Google云端硬盘帐户时看到了失败,但无法弄清问题是什么。

这是错误:

  

列出文件错误:后端错误   /mnt/opt/openera/current/app/models/cloud_account/google_drive.rb:299:in'list_files'   /mnt/opt/openera/current/app/models/cloud_account/google_drive.rb:220:in'do_discover_files'   /mnt/opt/openera/current/app/models/cloud_account/base.rb:304:'discover_files'   /mnt/opt/openera/current/app/workers/worker/file_synchronizer.rb:10:in'performance'   在/mmp / / /   处理'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:109:in'call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:109:in'block in in   voke”   /mnt/opt/openera/current/lib/sidekiq_repeat_jobs/middleware/server/repeat_jobs.rb:36:in'call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:111:in'block in in   voke”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/server/timeout.rb:14:in'cal   L”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:111:in'block in in   voke”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/server/active_record.rb:6:in   '呼叫'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:111:in'block in in   voke”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/server/retry_jobs.rb:49:in'   呼叫'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:111:in'block in in   voke”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/server/logging.rb:11:in'blo   ck in call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/logging.rb:22:in'with_context'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/server/logging.rb:7:in'call   “   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:111:in'block in in   voke”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:114:in'call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/middleware/chain.rb:114:in'revoke'   在/mmp / / /   处理'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/processor.rb:80:in'stats'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/sidekiq-2.6.5/lib/sidekiq/processor.rb:43:in'block in process'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in'call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/calls.rb:23:in'public_send'   在/mt / / /   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/future.rb:18:in'block in initiali   泽”   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in'call'   /mnt/opt/openera/current/vendor/bundle/ruby/1.9.1/gems/celluloid-0.12.4/lib/celluloid/internal_pool.rb:48:in'clock in c   reate'

更新:这是我们的高级开发人员的实际代码。

dev here(ffoeg)添加实际调用的代码:

def list_files
 pageToken = nil
 params = {'maxResults' => 65535, 'q' => 'trashed = false'}
 files = [] 
 drive = session.discovered_api("drive", "v2")
 while true do
   call_params = pageToken.blank? ? params : params.merge('pageToken' => pageToken)
   result = session.execute(api_method: drive.files.list, parameters: call_params)
   if result.status == 200
     files += result.data.items
     break if result.data['nextPageToken'].blank?
     pageToken = result.data['nextPageToken']
   else 
     raise "List Files Error: #{result.data['error']['message']}"
   end  
 end  
 files
end

再次更新:

我们更新了我们的代码以获得确切的错误 - 这就是:

List Files Error: {"errors"=>[{"domain"=>"global", "reason"=>"backendError", 
"message"=>"Backend Error"}], "code"=>503, "message"=>"Backend Error"}

1 个答案:

答案 0 :(得分:0)

问题是maxResults的价值。 太大,会导致请求超时。不幸的是,“安全”值非常小,每页约200个结果。您可以放大,但结果会因用户而异。具有较小语料库的用户可能会在较大页面大小的情况下正常工作,但具有较大语料库的用户似乎更敏感。好吧,至少基于对我的一些账户的一些非常快速/非正式的测试。

FWIW,我记得在页面尺寸较大的情况下工作效果更好。将检查是否有任何改变可能会限制超出预期的事情。