From 67de4c9c07f390cc45dfc33762d9e09229831045 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Wed, 16 Nov 2022 21:38:27 +0100 Subject: [PATCH] check more mime types for SeaweedFS dirs Signed-off-by: Nicola Murino --- internal/vfs/s3fs.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/vfs/s3fs.go b/internal/vfs/s3fs.go index c851625a..06975c78 100644 --- a/internal/vfs/s3fs.go +++ b/internal/vfs/s3fs.go @@ -60,6 +60,10 @@ const ( s3fsName = "S3Fs" ) +var ( + s3DirMimeTypes = []string{s3DirMimeType, "httpd/unix-directory"} +) + // S3Fs is a Fs implementation for AWS S3 compatible object storages type S3Fs struct { connectionID string @@ -159,9 +163,9 @@ func (fs *S3Fs) Stat(name string) (os.FileInfo, error) { } obj, err := fs.headObject(name) if err == nil { - // Some s3 providers (like seaweedfs) do not support traling '/' in object key. - // So We have to check Content-type of the object and detect that the object whether is an empty directory or an ordinary object. - isDir := util.GetStringFromPointer(obj.ContentType) == s3DirMimeType + // Some S3 providers (like SeaweedFS) remove the trailing '/' from object keys. + // So we check some common content types to detect if this is a "directory". + isDir := util.Contains(s3DirMimeTypes, util.GetStringFromPointer(obj.ContentType)) return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir, obj.ContentLength, util.GetTimeFromPointer(obj.LastModified), false)) }