From 8b60ab86a135a422eee281dc801cb638949d424d Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 29 Aug 2015 17:45:10 +0100 Subject: [PATCH] dropbox: force use of our custom transport which makes timeouts work --- dropbox/dropbox.go | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go index 216aa18ea..849f0f3ee 100644 --- a/dropbox/dropbox.go +++ b/dropbox/dropbox.go @@ -5,27 +5,6 @@ package dropbox Limitations of dropbox File system is case insensitive - -FIXME Getting this sometimes -Failed to copy: Upload failed: invalid character '<' looking for beginning of value -This is a JSON decode error - from Update / UploadByChunk -- Caused by 500 error from dropbox -- See https://github.com/stacktic/dropbox/issues/1 -- Possibly confusing dropbox with excess concurrency? - -FIXME implement timeouts - need to get "github.com/stacktic/dropbox" -and hence "golang.org/x/oauth2" which uses DefaultTransport unless it -is set in the context passed into .Client() - -func (db *Dropbox) client() *http.Client { - return db.config.Client(oauth2.NoContext, db.token) -} - -// HTTPClient is the context key to use with golang.org/x/net/context's -// WithValue function to associate an *http.Client value with a context. -var HTTPClient ContextKey - -So pass in a context with HTTPClient set... */ import ( @@ -41,6 +20,7 @@ import ( "time" "github.com/ncw/rclone/fs" + "github.com/ncw/rclone/oauthutil" "github.com/ogier/pflag" "github.com/stacktic/dropbox" ) @@ -172,6 +152,9 @@ func NewFs(name, root string) (fs.Fs, error) { // Read the token from the config file token := fs.ConfigFile.MustValue(name, "token") + // Set our custom context which enables our custom transport for timeouts etc + db.SetContext(oauthutil.Context()) + // Authorize the client db.SetAccessToken(token)