mirror of
https://github.com/rclone/rclone.git
synced 2025-02-02 19:49:46 +01:00
onedrive: changed QueryEscape to PathEscape - fixes #1296
This commit is contained in:
parent
2fd86c93fc
commit
e3a41321cc
@ -135,6 +135,14 @@ func parsePath(path string) (root string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mimics url.PathEscape which only available from go 1.8
|
||||||
|
func pathEscape(path string) string {
|
||||||
|
u := url.URL{
|
||||||
|
Path: path,
|
||||||
|
}
|
||||||
|
return u.EscapedPath()
|
||||||
|
}
|
||||||
|
|
||||||
// retryErrorCodes is a slice of error codes that we will retry
|
// retryErrorCodes is a slice of error codes that we will retry
|
||||||
var retryErrorCodes = []int{
|
var retryErrorCodes = []int{
|
||||||
429, // Too Many Requests.
|
429, // Too Many Requests.
|
||||||
@ -161,7 +169,7 @@ func shouldRetry(resp *http.Response, err error) (bool, error) {
|
|||||||
func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Response, err error) {
|
func (f *Fs) readMetaDataForPath(path string) (info *api.Item, resp *http.Response, err error) {
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: "/drive/root:/" + url.QueryEscape(replaceReservedChars(path)),
|
Path: "/drive/root:/" + pathEscape(replaceReservedChars(path)),
|
||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
resp, err = f.srv.CallJSON(&opts, nil, &info)
|
resp, err = f.srv.CallJSON(&opts, nil, &info)
|
||||||
@ -849,7 +857,7 @@ func (o *Object) ModTime() time.Time {
|
|||||||
func (o *Object) setModTime(modTime time.Time) (*api.Item, error) {
|
func (o *Object) setModTime(modTime time.Time) (*api.Item, error) {
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "PATCH",
|
Method: "PATCH",
|
||||||
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()),
|
Path: "/drive/root:/" + pathEscape(o.srvPath()),
|
||||||
}
|
}
|
||||||
update := api.SetFileSystemInfo{
|
update := api.SetFileSystemInfo{
|
||||||
FileSystemInfo: api.FileSystemInfoFacet{
|
FileSystemInfo: api.FileSystemInfoFacet{
|
||||||
@ -904,7 +912,7 @@ func (o *Object) Open(options ...fs.OpenOption) (in io.ReadCloser, err error) {
|
|||||||
func (o *Object) createUploadSession() (response *api.CreateUploadResponse, err error) {
|
func (o *Object) createUploadSession() (response *api.CreateUploadResponse, err error) {
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/upload.createSession",
|
Path: "/drive/root:/" + pathEscape(o.srvPath()) + ":/upload.createSession",
|
||||||
}
|
}
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
@ -1019,7 +1027,7 @@ func (o *Object) Update(in io.Reader, src fs.ObjectInfo) (err error) {
|
|||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/content",
|
Path: "/drive/root:/" + pathEscape(o.srvPath()) + ":/content",
|
||||||
Body: in,
|
Body: in,
|
||||||
}
|
}
|
||||||
// for go1.8 (see release notes) we must nil the Body if we want a
|
// for go1.8 (see release notes) we must nil the Body if we want a
|
||||||
|
Loading…
Reference in New Issue
Block a user