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