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"
|
2022-09-21 17:09:50 +02:00
|
|
|
)
|
|
|
|
|
2023-12-05 12:11:29 +01:00
|
|
|
func (b *s3Backend) entryListR(bucket, fdPath, name string, addPrefix bool, response *gofakes3.ObjectList) error {
|
2022-09-21 17:09:50 +02:00
|
|
|
fp := path.Join(bucket, fdPath)
|
|
|
|
|
2023-11-13 17:40:34 +01:00
|
|
|
dirEntries, err := getDirEntries(fp, b.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
|
|
|
|
}
|
2023-11-13 17:40:34 +01:00
|
|
|
err := b.entryListR(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
|
|
|
|
}
|