dbox 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/History.txt +4 -0
  2. data/VERSION +1 -1
  3. data/dbox.gemspec +2 -2
  4. data/lib/dbox/api.rb +17 -4
  5. metadata +4 -4
@@ -1,3 +1,7 @@
1
+ == 0.7.3 / 2012-12-23
2
+ * Minor Enhancements
3
+ * Added retry on all failed operations, not just rate limiting, to be more resilient with API errors.
4
+
1
5
  == 0.7.2 / 2012-12-04
2
6
  * Minor Enhancements
3
7
  * Added configurable Dropbox access type (sandbox or app_folder).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "dbox"
8
- s.version = "0.7.2"
8
+ s.version = "0.7.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ken Pratt"]
12
- s.date = "2012-12-04"
12
+ s.date = "2012-12-23"
13
13
  s.description = "An easy-to-use Dropbox client with fine-grained control over syncs."
14
14
  s.email = "ken@kenpratt.net"
15
15
  s.executables = ["dbox"]
@@ -76,15 +76,28 @@ module Dbox
76
76
  rescue DropboxAuthError => e
77
77
  raise e
78
78
  rescue DropboxError => e
79
- if e.http_response.kind_of?(Net::HTTPServiceUnavailable) && tries > 0
80
- log.info "Encountered 503 on #{path} (likely rate limiting). Sleeping #{TIME_BETWEEN_TRIES}s and trying again."
81
- # TODO check for "Retry-After" header and use that for sleep instead of TIME_BETWEEN_TRIES
82
- log.debug "Headers: #{e.http_response.to_hash.inspect}"
79
+ if tries > 0
80
+ if e.http_response.kind_of?(Net::HTTPServiceUnavailable)
81
+ log.info "Encountered 503 on #{path} (likely rate limiting). Sleeping #{TIME_BETWEEN_TRIES}s and trying again."
82
+ # TODO check for "Retry-After" header and use that for sleep instead of TIME_BETWEEN_TRIES
83
+ log.info "Headers: #{e.http_response.to_hash.inspect}"
84
+ else
85
+ log.info "Encountered a dropbox error. Sleeping #{TIME_BETWEEN_TRIES}s and trying again. Error: #{e.inspect}"
86
+ log.info "Headers: #{e.http_response.to_hash.inspect}"
87
+ end
83
88
  sleep TIME_BETWEEN_TRIES
84
89
  run(path, tries - 1, &proc)
85
90
  else
86
91
  handle_response(path, e.http_response) { raise ServerError, "Server error -- might be a hiccup, please try your request again (#{e.message})" }
87
92
  end
93
+ rescue Exception => e
94
+ if tries > 0
95
+ log.info "Encounted an unknown error. Sleeping #{TIME_BETWEEN_TRIES}s and trying again. Error: #{e.inspect}"
96
+ sleep TIME_BETWEEN_TRIES
97
+ run(path, tries - 1, &proc)
98
+ else
99
+ raise e
100
+ end
88
101
  end
89
102
  end
90
103
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 2
10
- version: 0.7.2
9
+ - 3
10
+ version: 0.7.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Pratt
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-04 00:00:00 Z
18
+ date: 2012-12-23 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: multipart-post