From a5fbb82fc865c0c3468fe5c4379f9af2989eddb6 Mon Sep 17 00:00:00 2001 From: junlee Date: Mon, 11 Mar 2024 18:14:26 +0800 Subject: [PATCH] fix gateway head dir return 200 but expect 404 --- pkg/gateway/gateway.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/gateway/gateway.go b/pkg/gateway/gateway.go index 1f89f621eeb7..647764a13d68 100644 --- a/pkg/gateway/gateway.go +++ b/pkg/gateway/gateway.go @@ -623,8 +623,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 }