diff --git a/src/GridFS/GridFSAdapter.php b/src/GridFS/GridFSAdapter.php index 382d45759..d5d44a1c6 100644 --- a/src/GridFS/GridFSAdapter.php +++ b/src/GridFS/GridFSAdapter.php @@ -280,17 +280,17 @@ public function lastModified(string $path): FileAttributes public function metadata(string $path, Config $config): StorageAttributes { - $file = $this->findFile($path); - - if ($file !== null) { - return $this->mapFileAttributes($file); - } - if ($this->directoryExists($path)) { return new DirectoryAttributes($path); } - throw UnableToRetrieveMetadata::metadata($path, 'file does not exist'); + $file = $this->findFile($path); + + if ($file === null) { + throw UnableToRetrieveMetadata::metadata($path, 'file does not exist'); + } + + return $this->mapFileAttributes($file); } public function listContents(string $path, bool $deep): iterable