1
mirror of https://github.com/rclone/rclone synced 2024-11-27 05:23:40 +01:00

onedrive: fix URL escaping in file names - eg uploading files with + in them.

Fixes #620
Fixes #218
This commit is contained in:
Nick Craig-Wood 2016-08-22 10:58:49 +01:00
parent bbccf4acd5
commit 79eebf1993

View File

@ -8,6 +8,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"regexp"
"strings"
"time"
@ -145,7 +146,7 @@ func shouldRetry(resp *http.Response, err error) (bool, error) {
func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Response, err error) {
opts := rest.Opts{
Method: "GET",
Path: "/drive/root:/" + replaceReservedChars(path),
Path: "/drive/root:/" + url.QueryEscape(replaceReservedChars(path)),
}
err = f.pacer.Call(func() (bool, error) {
resp, err = f.srv.CallJSON(&opts, nil, &info)
@ -738,7 +739,7 @@ func (o *Object) ModTime() time.Time {
func (o *Object) setModTime(modTime time.Time) (*api.Item, error) {
opts := rest.Opts{
Method: "PATCH",
Path: "/drive/root:/" + o.srvPath(),
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()),
}
update := api.SetFileSystemInfo{
FileSystemInfo: api.FileSystemInfoFacet{
@ -793,7 +794,7 @@ func (o *Object) Open() (in io.ReadCloser, err error) {
func (o *Object) createUploadSession() (response *api.CreateUploadResponse, err error) {
opts := rest.Opts{
Method: "POST",
Path: "/drive/root:/" + o.srvPath() + ":/upload.createSession",
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/upload.createSession",
}
var resp *http.Response
err = o.fs.pacer.Call(func() (bool, error) {
@ -903,7 +904,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) {
var resp *http.Response
opts := rest.Opts{
Method: "PUT",
Path: "/drive/root:/" + o.srvPath() + ":/content",
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/content",
Body: in,
}
err = o.fs.pacer.CallNoRetry(func() (bool, error) {