mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 15:28:05 +03:00
Handle empty directories with mimetype
Signed-off-by: Amir.h Yeganemehr <yeganemehr@jeyserver.com>
This commit is contained in:
committed by
Nicola Murino
parent
5a222807b7
commit
6591769a07
@@ -159,8 +159,10 @@ 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 {
|
||||||
// a "dir" has a trailing "/" so we cannot have a directory here
|
// Some s3 providers (like seaweedfs) do not support traling '/' in object key.
|
||||||
return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, false, obj.ContentLength,
|
// 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
|
||||||
|
return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir, obj.ContentLength,
|
||||||
util.GetTimeFromPointer(obj.LastModified), false))
|
util.GetTimeFromPointer(obj.LastModified), false))
|
||||||
}
|
}
|
||||||
if !fs.IsNotExist(err) {
|
if !fs.IsNotExist(err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user