mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
internetarchive: fix server side copy files with spaces
In this commit we broke server side copy for files with spaces
4c5764204d internetarchive: fix server side copy files with &
This fixes the problem by using rest.URLPathEscapeAll which escapes
everything possible.
Fixes #8754
This commit is contained in:
@@ -590,7 +590,7 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration,
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
bucket, bucketPath := f.split(remote)
|
bucket, bucketPath := f.split(remote)
|
||||||
return path.Join(f.opt.FrontEndpoint, "/download/", bucket, quotePath(bucketPath)), nil
|
return path.Join(f.opt.FrontEndpoint, "/download/", bucket, rest.URLPathEscapeAll(bucketPath)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy src to this remote using server-side copy operations.
|
// Copy src to this remote using server-side copy operations.
|
||||||
@@ -622,7 +622,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (_ fs.Objec
|
|||||||
"x-archive-auto-make-bucket": "1",
|
"x-archive-auto-make-bucket": "1",
|
||||||
"x-archive-queue-derive": "0",
|
"x-archive-queue-derive": "0",
|
||||||
"x-archive-keep-old-version": "0",
|
"x-archive-keep-old-version": "0",
|
||||||
"x-amz-copy-source": quotePath(path.Join("/", srcBucket, srcPath)),
|
"x-amz-copy-source": rest.URLPathEscapeAll(path.Join("/", srcBucket, srcPath)),
|
||||||
"x-amz-metadata-directive": "COPY",
|
"x-amz-metadata-directive": "COPY",
|
||||||
"x-archive-filemeta-sha1": srcObj.sha1,
|
"x-archive-filemeta-sha1": srcObj.sha1,
|
||||||
"x-archive-filemeta-md5": srcObj.md5,
|
"x-archive-filemeta-md5": srcObj.md5,
|
||||||
@@ -778,7 +778,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
|||||||
// make a GET request to (frontend)/download/:item/:path
|
// make a GET request to (frontend)/download/:item/:path
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
Path: path.Join("/download/", o.fs.root, quotePath(o.fs.opt.Enc.FromStandardPath(o.remote))),
|
Path: path.Join("/download/", o.fs.root, rest.URLPathEscapeAll(o.fs.opt.Enc.FromStandardPath(o.remote))),
|
||||||
Options: optionsFixed,
|
Options: optionsFixed,
|
||||||
}
|
}
|
||||||
err = o.fs.pacer.Call(func() (bool, error) {
|
err = o.fs.pacer.Call(func() (bool, error) {
|
||||||
@@ -1334,16 +1334,6 @@ func trimPathPrefix(s, prefix string, enc encoder.MultiEncoder) string {
|
|||||||
return enc.ToStandardPath(strings.TrimPrefix(s, prefix+"/"))
|
return enc.ToStandardPath(strings.TrimPrefix(s, prefix+"/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// mimics urllib.parse.quote() on Python; exclude / from url.PathEscape
|
|
||||||
func quotePath(s string) string {
|
|
||||||
seg := strings.Split(s, "/")
|
|
||||||
newValues := []string{}
|
|
||||||
for _, v := range seg {
|
|
||||||
newValues = append(newValues, url.QueryEscape(v))
|
|
||||||
}
|
|
||||||
return strings.Join(newValues, "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ fs.Fs = &Fs{}
|
_ fs.Fs = &Fs{}
|
||||||
_ fs.Copier = &Fs{}
|
_ fs.Copier = &Fs{}
|
||||||
|
|||||||
Reference in New Issue
Block a user