ruby-box 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/ruby-box/folder.rb +15 -1
- data/lib/ruby-box/session.rb +6 -1
- data/ruby-box.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTU5ODI5ODE2MGFlOTRiODk3MzNlOTA1MThhNDY2NTAwZTc1MDdhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmJjNTdkZmZjNzVmN2U3YjcyMmM0YzVhZTgzZTE5YzUyYjA5YTNiNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWQzMjMwMmE4ZTgxMmE3OTU2OWVkNDI0NTllODUwNTJiMjY1YzU5MzRlMzE1
|
10
|
+
YTJlNWJhMmQ2Nzk3NjU5Y2IxZDM3YjU5NGQ2OTllYjJjYWYyYjg4MDhlYjk3
|
11
|
+
NGY3ZGZhYjkzMWViMGE5NDRlNjM1YWVjYTM0YjMwZTcwMWVlOTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWJmYWNmNzViMWY3YjVlYmVkODdhODE0M2Y0MTUzMTQyYzAxZjU0ZjQ5ZGM4
|
14
|
+
M2U5NzI2OWE3MjdiOGQwODU2NjNiYjQxNmVjN2U5ZmExZjE1NGY4ODIzNjA4
|
15
|
+
NGYzNGQzMzg0ZGZhZWRkYjQ0M2ZmOTNkMzgzZTJlZjYyZjY3ZDM=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.9.0
|
data/lib/ruby-box/folder.rb
CHANGED
@@ -23,7 +23,21 @@ module RubyBox
|
|
23
23
|
resp = file.upload_content(data) #write a new file. If there is a conflict, update the conflicted file.
|
24
24
|
rescue RubyBox::ItemNameInUse => e
|
25
25
|
data.rewind
|
26
|
-
|
26
|
+
|
27
|
+
# The Box API occasionally does not return
|
28
|
+
# context info for an ItemNameInUse exception.
|
29
|
+
# This is a workaround around:
|
30
|
+
begin
|
31
|
+
# were were given context information about this conflict?
|
32
|
+
file = RubyBox::File.new(@session, {
|
33
|
+
'id' => e['context_info']['conflicts'][0]['id']
|
34
|
+
})
|
35
|
+
rescue
|
36
|
+
# we were not given context information about this conflict.
|
37
|
+
# attempt to lookup the file.
|
38
|
+
file = files(filename).pop
|
39
|
+
end
|
40
|
+
|
27
41
|
resp = file.update_content( data )
|
28
42
|
end
|
29
43
|
end
|
data/lib/ruby-box/session.rb
CHANGED
@@ -9,7 +9,10 @@ module RubyBox
|
|
9
9
|
:token_url => "/api/oauth2/token"
|
10
10
|
}
|
11
11
|
|
12
|
-
def initialize(opts={})
|
12
|
+
def initialize(opts={}, backoff=0.1)
|
13
|
+
|
14
|
+
@backoff = backoff # try not to excessively hammer API.
|
15
|
+
|
13
16
|
if opts[:client_id]
|
14
17
|
@oauth2_client = OAuth2::Client.new(opts[:client_id], opts[:client_secret], OAUTH2_URLS.dup)
|
15
18
|
@access_token = OAuth2::AccessToken.new(@oauth2_client, opts[:access_token]) if opts[:access_token]
|
@@ -74,6 +77,8 @@ module RubyBox
|
|
74
77
|
request(uri, request, raw, retries + 1)
|
75
78
|
end
|
76
79
|
|
80
|
+
sleep(@backoff) # try not to excessively hammer API.
|
81
|
+
|
77
82
|
handle_errors( response.code.to_i, response.body, raw )
|
78
83
|
end
|
79
84
|
|
data/ruby-box.gemspec
CHANGED