2022-09-21 17:09:50 +02:00
|
|
|
package s3
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
|
2024-04-13 18:50:11 +02:00
|
|
|
"github.com/rclone/gofakes3"
|
2024-07-17 16:14:08 +02:00
|
|
|
"github.com/rclone/rclone/vfs"
|
2022-09-21 17:09:50 +02:00
|
|
|
)
|
|
|
|
|
2024-07-17 16:14:08 +02:00
|
|
|
func (b *s3Backend) entryListR(_vfs *vfs.VFS, bucket, fdPath, name string, addPrefix bool, response *gofakes3.ObjectList) error {
|
2022-09-21 17:09:50 +02:00
|
|
|
fp := path.Join(bucket, fdPath)
|
|
|
|
|
2024-07-17 16:14:08 +02:00
|
|
|
dirEntries, err := getDirEntries(fp, _vfs)
|
2022-09-21 17:09:50 +02:00
|
|
|
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() {
|
2023-12-05 12:11:29 +01:00
|
|
|
if addPrefix {
|
2022-09-21 17:09:50 +02:00
|
|
|
response.AddPrefix(gofakes3.URLEncode(objectPath))
|
|
|
|
continue
|
|
|
|
}
|
2024-07-17 16:14:08 +02:00
|
|
|
err := b.entryListR(_vfs, bucket, path.Join(fdPath, object), "", false, response)
|
2022-09-21 17:09:50 +02:00
|
|
|
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
|
|
|
|
}
|