mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
S3: improve "directories" detection
Fixes #1097 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -165,6 +165,10 @@ func (fs *S3Fs) Stat(name string) (os.FileInfo, error) {
|
|||||||
// Some S3 providers (like SeaweedFS) remove the trailing '/' from object keys.
|
// 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".
|
// So we check some common content types to detect if this is a "directory".
|
||||||
isDir := util.Contains(s3DirMimeTypes, util.GetStringFromPointer(obj.ContentType))
|
isDir := util.Contains(s3DirMimeTypes, util.GetStringFromPointer(obj.ContentType))
|
||||||
|
if obj.ContentLength == 0 && !isDir {
|
||||||
|
_, err = fs.headObject(name + "/")
|
||||||
|
isDir = err == nil
|
||||||
|
}
|
||||||
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