Skip to content

Commit

Permalink
gateway: fix gateway head dir return 200 but expect 404 (#4486)
Browse files Browse the repository at this point in the history
  • Loading branch information
li1213987842 authored and SandyXSD committed Jun 19, 2024
1 parent e7f99fc commit 64219aa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,15 @@ func (n *jfsObjects) GetObjectInfo(ctx context.Context, bucket, object string, o
err = jfsToObjectErr(ctx, eno, bucket, object)
return
}
// put /dir1/key1; head /dir1 return 404; head /dir1/ return 200
if strings.HasSuffix(object, sep) && !fi.IsDir() || !strings.HasSuffix(object, sep) && fi.IsDir() {
// put /dir1/key1; head /dir1 return 404; head /dir1/ return 404; head /dir1/key1 return 200
// put /dir1/key1/; head /dir1/key1 return 404; head /dir1/key1/ return 200
var isObject bool
if strings.HasSuffix(object, sep) && fi.IsDir() && fi.Atime() == 0 {
isObject = true
} else if !strings.HasSuffix(object, sep) && !fi.IsDir() {
isObject = true
}
if !isObject {
err = jfsToObjectErr(ctx, syscall.ENOENT, bucket, object)
return
}
Expand Down

0 comments on commit 64219aa

Please sign in to comment.