s3: use bucket.Join instead of path.Join to preserve paths
Before this change, path.Join would remove the trailing / from objects which had them. The simplified bucket.Join does not.
This commit is contained in:
parent
d7ad13d929
commit
de9c4a3611
1 changed files with 4 additions and 4 deletions
|
@ -2534,7 +2534,7 @@ func parsePath(path string) (root string) {
|
||||||
// split returns bucket and bucketPath from the rootRelativePath
|
// split returns bucket and bucketPath from the rootRelativePath
|
||||||
// relative to f.root
|
// relative to f.root
|
||||||
func (f *Fs) split(rootRelativePath string) (bucketName, bucketPath string) {
|
func (f *Fs) split(rootRelativePath string) (bucketName, bucketPath string) {
|
||||||
bucketName, bucketPath = bucket.Split(path.Join(f.root, rootRelativePath))
|
bucketName, bucketPath = bucket.Split(bucket.Join(f.root, rootRelativePath))
|
||||||
return f.opt.Enc.FromStandardName(bucketName), f.opt.Enc.FromStandardPath(bucketPath)
|
return f.opt.Enc.FromStandardName(bucketName), f.opt.Enc.FromStandardPath(bucketPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3589,7 +3589,7 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error {
|
||||||
}
|
}
|
||||||
remote = remote[len(opt.prefix):]
|
remote = remote[len(opt.prefix):]
|
||||||
if opt.addBucket {
|
if opt.addBucket {
|
||||||
remote = path.Join(opt.bucket, remote)
|
remote = bucket.Join(opt.bucket, remote)
|
||||||
}
|
}
|
||||||
remote = strings.TrimSuffix(remote, "/")
|
remote = strings.TrimSuffix(remote, "/")
|
||||||
err = fn(remote, &s3.Object{Key: &remote}, nil, true)
|
err = fn(remote, &s3.Object{Key: &remote}, nil, true)
|
||||||
|
@ -3618,7 +3618,7 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error {
|
||||||
remote = remote[len(opt.prefix):]
|
remote = remote[len(opt.prefix):]
|
||||||
isDirectory := remote == "" || strings.HasSuffix(remote, "/")
|
isDirectory := remote == "" || strings.HasSuffix(remote, "/")
|
||||||
if opt.addBucket {
|
if opt.addBucket {
|
||||||
remote = path.Join(opt.bucket, remote)
|
remote = bucket.Join(opt.bucket, remote)
|
||||||
}
|
}
|
||||||
// is this a directory marker?
|
// is this a directory marker?
|
||||||
if isDirectory && object.Size != nil && *object.Size == 0 {
|
if isDirectory && object.Size != nil && *object.Size == 0 {
|
||||||
|
@ -3911,7 +3911,7 @@ func (f *Fs) copy(ctx context.Context, req *s3.CopyObjectInput, dstBucket, dstPa
|
||||||
req.Bucket = &dstBucket
|
req.Bucket = &dstBucket
|
||||||
req.ACL = stringPointerOrNil(f.opt.ACL)
|
req.ACL = stringPointerOrNil(f.opt.ACL)
|
||||||
req.Key = &dstPath
|
req.Key = &dstPath
|
||||||
source := pathEscape(path.Join(srcBucket, srcPath))
|
source := pathEscape(bucket.Join(srcBucket, srcPath))
|
||||||
if src.versionID != nil {
|
if src.versionID != nil {
|
||||||
source += fmt.Sprintf("?versionId=%s", *src.versionID)
|
source += fmt.Sprintf("?versionId=%s", *src.versionID)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue