mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 15:38:57 +01:00
dropbox: force use of our custom transport which makes timeouts work
This commit is contained in:
parent
7463a7a509
commit
8b60ab86a1
@ -5,27 +5,6 @@ package dropbox
|
|||||||
Limitations of dropbox
|
Limitations of dropbox
|
||||||
|
|
||||||
File system is case insensitive
|
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 (
|
import (
|
||||||
@ -41,6 +20,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
|
"github.com/ncw/rclone/oauthutil"
|
||||||
"github.com/ogier/pflag"
|
"github.com/ogier/pflag"
|
||||||
"github.com/stacktic/dropbox"
|
"github.com/stacktic/dropbox"
|
||||||
)
|
)
|
||||||
@ -172,6 +152,9 @@ func NewFs(name, root string) (fs.Fs, error) {
|
|||||||
// Read the token from the config file
|
// Read the token from the config file
|
||||||
token := fs.ConfigFile.MustValue(name, "token")
|
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
|
// Authorize the client
|
||||||
db.SetAccessToken(token)
|
db.SetAccessToken(token)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user