mirror of
https://github.com/alist-org/gofakes3.git
synced 2025-12-24 12:58:04 +08:00
Support create Dir and listBucket add Dir info
(cherry picked from commit eecd8095d80ccb6922ec87e7e214b5880a047899)
This commit is contained in:
26
gofakes3.go
26
gofakes3.go
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
@@ -246,6 +247,31 @@ func (g *GoFakeS3) listBucket(bucketName string, w http.ResponseWriter, r *http.
|
||||
|
||||
ctx := r.Context()
|
||||
objects, err := g.storage.ListBucket(ctx, bucketName, &prefix, page)
|
||||
log.Debugf("objects.Contents: %v, prefix: %v", objects.Contents, prefix)
|
||||
|
||||
hasPrefixSelf := false
|
||||
if objects.Contents != nil {
|
||||
for _, v := range objects.Contents {
|
||||
if v.Key == prefix.Prefix {
|
||||
hasPrefixSelf = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasPrefixSelf {
|
||||
log.Infof("objects.Contents not has prefix self, need to add it.")
|
||||
objects.Contents = append(objects.Contents, &Content{
|
||||
Key: prefix.Prefix,
|
||||
LastModified: NewContentTime(time.Time{}),
|
||||
ETag: "",
|
||||
Size: 0,
|
||||
StorageClass: StorageStandard,
|
||||
Owner: nil,
|
||||
})
|
||||
}
|
||||
log.Debugf("objects.Contents: %v", objects.Contents)
|
||||
|
||||
if err != nil {
|
||||
if err == ErrInternalPageNotImplemented && !g.failOnUnimplementedPage {
|
||||
// We have observed (though not yet confirmed) that simple clients
|
||||
|
||||
@@ -55,6 +55,9 @@ func (g *GoFakeS3) routeBase(w http.ResponseWriter, r *http.Request) {
|
||||
err = g.routeVersion(bucket, object, VersionID(versionID), w, r)
|
||||
|
||||
} else if bucket != "" && object != "" {
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
object = object + "/"
|
||||
}
|
||||
err = g.routeObject(bucket, object, w, r)
|
||||
|
||||
} else if bucket != "" {
|
||||
|
||||
Reference in New Issue
Block a user