From 23774353b7068f6a411d3134e81fac075369449e Mon Sep 17 00:00:00 2001 From: ebozduman Date: Fri, 21 Aug 2020 13:08:01 -0700 Subject: [PATCH] get_object() returns NoSuchKey error when object is a prefix (#10315) --- cmd/fs-v1.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index bac35f6ae..fc5d55bee 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -709,7 +709,7 @@ func (fs *FSObjects) GetObjectNInfo(ctx context.Context, bucket, object string, nsUnlocker() return nil, toObjectErr(err, bucket, object) } - // For a directory, we need to send an reader that returns no bytes. + // For a directory, we need to return a reader that returns no bytes. if HasSuffix(object, SlashSeparator) { // The lock taken above is released when // objReader.Close() is called by the caller. @@ -958,6 +958,10 @@ func (fs *FSObjects) getObjectInfoNoFSLock(ctx context.Context, bucket, object s // getObjectInfo - wrapper for reading object metadata and constructs ObjectInfo. func (fs *FSObjects) getObjectInfo(ctx context.Context, bucket, object string) (oi ObjectInfo, e error) { + if strings.HasSuffix(object, SlashSeparator) && !fs.isObjectDir(bucket, object) { + return oi, errFileNotFound + } + fsMeta := fsMetaV1{} if HasSuffix(object, SlashSeparator) { fi, err := fsStatDir(ctx, pathJoin(fs.fsPath, bucket, object))