mirror of
https://github.com/rclone/rclone
synced 2024-11-08 05:31:41 +01:00
onedrive: fix URL escaping in file names - eg uploading files with +
in them.
Fixes #620 Fixes #218
This commit is contained in:
parent
bbccf4acd5
commit
79eebf1993
@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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) {
|
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:/" + replaceReservedChars(path),
|
Path: "/drive/root:/" + url.QueryEscape(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)
|
||||||
@ -738,7 +739,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:/" + o.srvPath(),
|
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()),
|
||||||
}
|
}
|
||||||
update := api.SetFileSystemInfo{
|
update := api.SetFileSystemInfo{
|
||||||
FileSystemInfo: api.FileSystemInfoFacet{
|
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) {
|
func (o *Object) createUploadSession() (response *api.CreateUploadResponse, err error) {
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/drive/root:/" + o.srvPath() + ":/upload.createSession",
|
Path: "/drive/root:/" + url.QueryEscape(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) {
|
||||||
@ -903,7 +904,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:/" + o.srvPath() + ":/content",
|
Path: "/drive/root:/" + url.QueryEscape(o.srvPath()) + ":/content",
|
||||||
Body: in,
|
Body: in,
|
||||||
}
|
}
|
||||||
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
|
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user