mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
check more mime types for SeaweedFS dirs
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -60,6 +60,10 @@ const (
|
|||||||
s3fsName = "S3Fs"
|
s3fsName = "S3Fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
s3DirMimeTypes = []string{s3DirMimeType, "httpd/unix-directory"}
|
||||||
|
)
|
||||||
|
|
||||||
// S3Fs is a Fs implementation for AWS S3 compatible object storages
|
// S3Fs is a Fs implementation for AWS S3 compatible object storages
|
||||||
type S3Fs struct {
|
type S3Fs struct {
|
||||||
connectionID string
|
connectionID string
|
||||||
@@ -159,9 +163,9 @@ func (fs *S3Fs) Stat(name string) (os.FileInfo, error) {
|
|||||||
}
|
}
|
||||||
obj, err := fs.headObject(name)
|
obj, err := fs.headObject(name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Some s3 providers (like seaweedfs) do not support traling '/' in object key.
|
// Some S3 providers (like SeaweedFS) remove the trailing '/' from object keys.
|
||||||
// So We have to check Content-type of the object and detect that the object whether is an empty directory or an ordinary object.
|
// So we check some common content types to detect if this is a "directory".
|
||||||
isDir := util.GetStringFromPointer(obj.ContentType) == s3DirMimeType
|
isDir := util.Contains(s3DirMimeTypes, util.GetStringFromPointer(obj.ContentType))
|
||||||
return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir, obj.ContentLength,
|
return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir, obj.ContentLength,
|
||||||
util.GetTimeFromPointer(obj.LastModified), false))
|
util.GetTimeFromPointer(obj.LastModified), false))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user