mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 11:41:17 +08:00
9de485f949
This implements --auth-proxy for serve s3. In addition it: * add listbuckets tests with and without authProxy * use auth proxy test framework * servetest: implement workaround for #7454 * update github.com/rclone/gofakes3 to fix race condition
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package s3
|
|
|
|
import (
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/rclone/gofakes3"
|
|
"github.com/rclone/rclone/vfs"
|
|
)
|
|
|
|
func (b *s3Backend) entryListR(_vfs *vfs.VFS, bucket, fdPath, name string, addPrefix bool, response *gofakes3.ObjectList) error {
|
|
fp := path.Join(bucket, fdPath)
|
|
|
|
dirEntries, err := getDirEntries(fp, _vfs)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, entry := range dirEntries {
|
|
object := entry.Name()
|
|
|
|
// workround for control-chars detect
|
|
objectPath := path.Join(fdPath, object)
|
|
|
|
if !strings.HasPrefix(object, name) {
|
|
continue
|
|
}
|
|
|
|
if entry.IsDir() {
|
|
if addPrefix {
|
|
response.AddPrefix(gofakes3.URLEncode(objectPath))
|
|
continue
|
|
}
|
|
err := b.entryListR(_vfs, bucket, path.Join(fdPath, object), "", false, response)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
item := &gofakes3.Content{
|
|
Key: gofakes3.URLEncode(objectPath),
|
|
LastModified: gofakes3.NewContentTime(entry.ModTime()),
|
|
ETag: getFileHash(entry),
|
|
Size: entry.Size(),
|
|
StorageClass: gofakes3.StorageStandard,
|
|
}
|
|
response.Add(item)
|
|
}
|
|
}
|
|
return nil
|
|
}
|