aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-02-25 11:13:06 -0800
committerChris Lu <chris.lu@gmail.com>2020-02-25 11:13:06 -0800
commit7d10fdf73720fb3234cd5cacfaf10fb79590d754 (patch)
tree3c8d1170824d605bdb6532cf657b85824fd848dd /weed/s3api
parente86da5a4918e0cf663a8c592387c72c850647e4e (diff)
downloadseaweedfs-7d10fdf73720fb3234cd5cacfaf10fb79590d754.tar.xz
seaweedfs-7d10fdf73720fb3234cd5cacfaf10fb79590d754.zip
fix directory lookup nil
Diffstat (limited to 'weed/s3api')
-rw-r--r--weed/s3api/filer_util.go4
-rw-r--r--weed/s3api/s3api_bucket_handlers.go5
2 files changed, 7 insertions, 2 deletions
diff --git a/weed/s3api/filer_util.go b/weed/s3api/filer_util.go
index 2fceacd2a..91c34f0eb 100644
--- a/weed/s3api/filer_util.go
+++ b/weed/s3api/filer_util.go
@@ -154,6 +154,10 @@ func (s3a *S3ApiServer) exists(ctx context.Context, parentDirectoryPath string,
glog.V(0).Infof("exists entry %v: %v", request, err)
return fmt.Errorf("exists entry %s/%s: %v", parentDirectoryPath, entryName, err)
}
+ if resp.Entry == nil {
+ exists = false
+ return nil
+ }
exists = resp.Entry.IsDirectory == isDirectory
diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go
index 492d94616..69275e212 100644
--- a/weed/s3api/s3api_bucket_handlers.go
+++ b/weed/s3api/s3api_bucket_handlers.go
@@ -11,9 +11,10 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
+ "github.com/gorilla/mux"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
- "github.com/gorilla/mux"
)
var (
@@ -119,7 +120,7 @@ func (s3a *S3ApiServer) HeadBucketHandler(w http.ResponseWriter, r *http.Request
}
glog.V(1).Infof("lookup bucket: %v", request)
- if _, err := client.LookupDirectoryEntry(ctx, request); err != nil {
+ if resp, err := client.LookupDirectoryEntry(ctx, request); err != nil || resp.Entry == nil {
return fmt.Errorf("lookup bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)
}