Procházet zdrojové kódy

S3: improve "directories" detection

Fixes #1097

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
Nicola Murino před 2 roky
rodič
revize
ac91170d65
1 změnil soubory, kde provedl 4 přidání a 0 odebrání
  1. 4 0
      internal/vfs/s3fs.go

+ 4 - 0
internal/vfs/s3fs.go

@@ -165,6 +165,10 @@ func (fs *S3Fs) Stat(name string) (os.FileInfo, error) {
 		// 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))
+		if obj.ContentLength == 0 && !isDir {
+			_, err = fs.headObject(name + "/")
+			isDir = err == nil
+		}
 		return updateFileInfoModTime(fs.getStorageID(), name, NewFileInfo(name, isDir, obj.ContentLength,
 			util.GetTimeFromPointer(obj.LastModified), false))
 	}