gcs: fix 400 Bad request errors when using multi-thread copy
Before this change, on every Open, we added the userProject parameter to the URL in the object. This meant it grew and grew until Google returned Error 400 (Bad Request) errors when the URL became too long. This fixes the problem by adding the userProject parameter once. See: https://forum.rclone.org/t/endlessly-repeating-userproject-parameter-in-get-to-google-storage-context-canceled-got-http-response-code-400/42652
This commit is contained in:
parent
4a3e9bbabf
commit
4ac5cb07ca
1 changed files with 3 additions and 2 deletions
|
@ -1310,10 +1310,11 @@ func (o *Object) Storable() bool {
|
|||
|
||||
// Open an object for read
|
||||
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error) {
|
||||
url := o.url
|
||||
if o.fs.opt.UserProject != "" {
|
||||
o.url = o.url + "&userProject=" + o.fs.opt.UserProject
|
||||
url += "&userProject=" + o.fs.opt.UserProject
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", o.url, nil)
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue